Skip to content

Instantly share code, notes, and snippets.

@AlirezaAkbarix
Last active February 26, 2018 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlirezaAkbarix/fe9be82bb944ef278e7e5286a418df99 to your computer and use it in GitHub Desktop.
Save AlirezaAkbarix/fe9be82bb944ef278e7e5286a418df99 to your computer and use it in GitHub Desktop.
NodeJs Getting Started (Creating an empty Server)
// #First HomeWork :)
const
http = require('http'),
host= '127.0.0.1',
port = 2999, // For showing my Creativity!
server = http.createServer( (req , res)=>{
res.statusCode = 200;
res.setHeader('Content-Type','text/html');
res.write('<p>Dalam :)</p>');
res.write('<p>Will it go to the next line?</p>');
res.write('<p>It <b>didn\'t</b> unless I used html</p>');
res.end();
}),
createMyServer = ()=>{
server.listen(3000,'127.0.0.1', ()=>{
console.log('Can anyone say why PORT is the first argument? :|');
});
};
createMyServer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment