Created
July 14, 2015 06:09
-
-
Save khamiltonuk/60e33eed760b0d59d97c to your computer and use it in GitHub Desktop.
helloworld.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| http.createServer(function(req,res){ | |
| // normalize url by removing querystring, optional | |
| var path = req.url.replace(/\/?(?:\?.*)?$/, '').toLowerCase(); | |
| switch(path){ | |
| case '': | |
| res.writeHead(200, {'Content-type': 'text/plain'}); | |
| res.end('Homepage'); | |
| break; | |
| case '/about': | |
| res.writeHead(200, {'Content-type': 'text/plain'}); | |
| res.end('About '); | |
| } | |
| }).listen(3000); | |
| console.log('server started on localhost:3000'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment