Skip to content

Instantly share code, notes, and snippets.

@elpuas
Last active Apr 1, 2021
Embed
What would you like to do?
const http = require( 'http' )
const server = http.createServer( ( req, res ) => {
console.log( req.url )
switch( req.url ) {
case '/':
res.end( 'The Homepage' )
break;
case '/about':
res.end( 'The About Page' )
break;
case '/contact':
res.end( 'The Contact Page' )
break;
default:
res.writeHead( 404 )
res.end()
}
} )
server.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment