Hello world in nodejs
- User
Hello world in nodejs
Assistant
Sure, here's a simple "Hello World" program in Node.js:
codeconst http = require('http'); const server = http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello, World!\n'); }); server.listen(3000, () => { console.log('Server running at http://localhost:3000/'); });This program uses the
httpmodule to create a simple HTTP server. The server is started by creating a newServerobject and passing in a function as theHandlerargument. The function is then called with a request object, which includes aHeadrequest header to indicate that the request should be treated as a no-op and anEndrequest header to indicate that the response should end with the string .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.