Skip to content

Instantly share code, notes, and snippets.

@gaspaonrocks
Created May 11, 2017 20:11
Show Gist options
  • Save gaspaonrocks/f32042353d92e804528bcb51baf42150 to your computer and use it in GitHub Desktop.
Save gaspaonrocks/f32042353d92e804528bcb51baf42150 to your computer and use it in GitHub Desktop.
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