the article shows nothing more than a first approach. for you, as a beginner, express is a better start to get results. follow this guide a bit http://expressjs.com/guide.html
your possible app.js: var express = require('express') var app = express() var db = require('mysql').createConnection() //serves html, js and css files from the path, automagicaly setting headers suitable for caching et al app.use(express.static('path/to/your/static/files')); app.get('/users/:id', function(req,res){ db.query('SELECT * FROM users WHERE id = ' + connection.escape(req.params.id), function(err,user){ if(!err) res.json(user) else res.send(500) }) }) try to start at the beginning. reade the guide, look at some reading resource on http://nodetoolbox.com/ , here on the mailinglist there are some topics gathering infos for beginners Am Mittwoch, 20. Februar 2013 15:05:52 UTC+1 schrieb kanitkar...@gmail.com: > > I went through the comments given by both of you. > I am certainly at initial stage of learning Node & thus have such > questions, but I will try to learn as much as I can and use your comments > as well. > BTW : what do you think of below link ? > ( > http://thecodinghumanist.com/blog/archives/2011/5/6/serving-static-files-from-node-js<https://mex07a.emailsrvr.com/owa/redir.aspx?C=0XUOyGttuk-E178ujGwQ4PWeAPyW4s9Ic5T8XNiO6uB0y_vWS3p3hQueay6fxh98syLG2dS89qU.&URL=http%3a%2f%2fthecodinghumanist.com%2fblog%2farchives%2f2011%2f5%2f6%2fserving-static-files-from-node-js> > ) > > > Is it a good way to code in Node & if not can you point me to a better > abstraction ? > Can you please provide a working example of sample web application done in > Node which has Html + CSS + jQuery + Node script files ? > > > It can be just hello world in which jQuery is used in some way & the > jQuery script tag is included in index.html file. > So Node server will serve index.html file & user can interact with jQuery > code. > > > If you can please provide the above to me it will be of help. Thanks again. > > On Wednesday, February 20, 2013 5:05:28 PM UTC+5:30, greelgorke wrote: >> >> > Still, don't let express be the next rails. >> >> it won't, in fact with mounted apps it goes right in to opposite >> direction, you can configure every piece of your app different and split >> them on different nodes w/o changing much. there are several frameworks >> built on top of express, that want to be the next rails, but i don't like >> them much. if i want rails, i'd rather use the original. express/connect >> are inspired by sinatara, but they do not hide nodes nature away so it's a >> good way for me. >> >> > Truth be told, judging from the questions you ask and thus the views I >> expect you have, you might want to take a step backwards and try and grasp >> what node.js really is, what it can do and what it is good at. Almost >> anything is possible, but if you keep seeing node the same way as your wamp >> installation, this will stop you from understanding node. Sure, with a few >> lines of code node can act like a static file server, but thats really not >> all there is. >> >> + gazilion to this. >> >> >> Am Mittwoch, 20. Februar 2013 12:14:11 UTC+1 schrieb Geerten van Meel: >>> >>> Lets say this again: With the setup above, you have the skeletton of >>> your own webserver that behaves exactly like you want it to. With that >>> setup, it acts like a static file server and can serve anything that is in >>> your assets folder ("/static"). You start your node server instead of wamp. >>> It acts roughly the same, except that it really does serve all files in >>> that folder as-is, no php preprocessing or the like. >>> >>> Also,* there is no Jade or Stylus involved*. At all. >>> >>> If you have a webpage that runs on wamp, and does not rely on backend >>> logic (no php files),* you can copy&paste it into your static file >>> folder* and it works right out of the box. Your webserver acts like a >>> plain static file server. The setup mentioned above is what you asked for >>> in #6. >>> >>> Note that .htaccess shenanigans are not supported, but you can do this >>> more elegantly in node anyways. To expose your api as you did using php, >>> you will need to get your hands dirty with node in the form of your own >>> route logic. express does make custom routing a bit easier on you, maybe >>> thats a better fit after all when you're starting out. You can still use it >>> without much of the extra features. >>> >>> Truth be told, judging from the questions you ask and thus the views I >>> expect you have, you might want to take a step backwards and try and grasp >>> what node.js really is, what it can do and what it is good at. Almost >>> anything is possible, but if you keep seeing node the same way as your wamp >>> installation, this will stop you from understanding node. Sure, with a few >>> lines of code node can act like a static file server, but thats really not >>> all there is. >>> >>> @Gregor: express does indeed evolve in the right direction; My initial >>> distaste when I first used it was based on its api inconsistencies and >>> conventions at a point when documentation was scarce and configuration >>> possibilities were very limited. This probably has improved by now and my >>> views in this regard are outdated. Still, don't let express be the next >>> rails. >>> >>> All the best, >>> >>> Geerten >>> >>> On Tuesday, February 19, 2013 3:35:53 PM UTC+1, kanitkar...@gmail.comwrote: >>>> >>>> Hi, >>>> >>>> I would like to do the following, >>>> >>>> 1) Have regular .html .css & .js files just like a normal web app >>>> >>>> 2) Interact with Node Js only through Ajax calls >>>> >>>> 3) But All files mentioned in 1) are also hosted on the same Node Http >>>> server. >>>> >>>> So when I say http://localhost:3000/index.html, Node Js server should >>>> give me index.html along with all css & js files included in it. >>>> >>>> Then my Javascript & Ajax code should drive the functionality with Node >>>> program getting called by ajax request. >>>> >>>> Can anyone please please suggest me the best way to do this ? >>>> >>>> I don't want to use Jade or Stylus. I want to develop as if I am using >>>> tomcat or wamp server & use power of Node where ever needed only. >>>> >>>> I am aware of express js framework but don't know how it will be useful >>>> for above scenario. >>>> >>> -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.