Using a code template Node.js
Asked by Илья Бабельник about a month ago
Greetings, wanted to see how this code snippet works on the playground
const http = require('http');
const hostname = '127.0.0.1'; const port = 3000;
const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World'); });
server.listen(port, hostname, () => { console.log(
Server running at http://${hostname}:${port}/
); });
I get the following line instead of some result:
Nothing really to see here, or 15 th3r3?
Can you tell me if I'm using the playground in the wrong way?
2 Answers
We are not sure why you were shown this message.
Here is the link to the playground with your code : https://codedamn.com/playground/CUY3DomegTa0g3by078MA
You can take a look at this playground on how to make this code run on codedamn playgrounds.
The host should always point to : 0.0.0.0
and the port used should be 1337
for the browser preview to display the output.
The following details already mentioned in the settings tab of the playground.
I hope this resolves your issue. If you have any more queries or problems with this, please let us know