Reputation: 1
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {//i create the server
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');//log to the console
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
//and its dont work its show me a syntax error //if someone can tell me how to fix this
Upvotes: 0
Views: 304
Reputation: 11
Don't double click on your js file, you have to launch it using nodejs :
You will have the output of your program in the terminal.
Upvotes: 1