Created
May 11, 2017 20:11
-
-
Save gaspaonrocks/f32042353d92e804528bcb51baf42150 to your computer and use it in GitHub Desktop.
This file contains 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
let http = require('http'); | |
let url = require('url'); | |
let port = 3000; | |
let server = http.createServer((request, response) => { | |
var page = url.parse(request.url).pathname; | |
console.log(page); | |
response.writeHead(200, { | |
'Content-Type': 'text/plain' | |
}) | |
if (page == '/about') { | |
response.write("what do you want to know about me... ? AMA !") | |
} else { | |
response.write("Hello NodeJS ! Welcome to my home page ;-)") | |
} | |
response.end() | |
}) | |
server.listen(port, (err) => { | |
if (err) | |
return console.log('something bad happened', err) | |
console.log(`server is listening on ${port}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment