Node how to start page – What’s the simplest way to create a basic page in Node.js? Alternatively: Nod

18 Replies, 1067 Views

Hey! For a super simple node how to start page, you can totally use just the core `http` module. Here's a quick snippet:

```javascript
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
});
server.listen(3000, () => console.log('Server running on port 3000'));
```

No Express needed! Just save this as `server.js` and run `node server.js`. Easy peasy.

Messages In This Thread



Users browsing this thread: 1 Guest(s)