app.get must be from some framework. It is not a part of node.
On Thu, Sep 12, 2013 at 1:29 PM, Jerome Hwang <[email protected]> wrote: > IMO, if you don't know much about web app, you could start by learning a > little of how it wroks for PHP, since PHP is built for web programming so > it'll be a lot easier to understand how web app works. > > Node.js can do a lot more things that's not just web app. (Experts please > correct me if I'm wrong) so it'll be harder to pick up. > > For Node, we have an *app.router* that we use to route any routes to any > content (not necessarily to be a HTML page) The URL " > http://localhost/index.html" does not necessarily mean that the user will > recieved the content of index.html in the root directory. We can decide > what to do with it with the following: > > app.get('/index.html', function(req, res){ > res.end('Hello World!'); > }) > > In the above case, we'll just return just the text "Hello World" and it's > not actually reading from any html page. > > In simple case in PHP though, "http://localhost/index.html" would just be > the index.html page in the root directory. > > Good Luck! > Jerome > > > > On Thu, Sep 12, 2013 at 3:19 PM, mscdex <[email protected]> wrote: > >> On Thursday, September 12, 2013 2:21:23 PM UTC-4, Mark Hahn wrote: >>> >>> change `res.end('Hello World\n'` to >>> >>> fs.readFile( yourFilePath, 'utf8', function(err, data) { res.end( >>> data); } ); >>> >>> >> Or better yet: fs.createReadStream(filePath).pipe(res); >> >> -- >> -- >> 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 [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> 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 [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > University of Illinois at Urbana-Champaign > College of Engineering | BS in Computer Science > Tel: (517)203-9077 | E-mail: [email protected] > > -- > -- > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- 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 [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
