Skip to content

Added a simple HTTP server example to the README.md to showcase basic… #58312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ that discourage, exhaust, or otherwise negatively affect other participants.
* [Collaborators](#collaborators)
* [Triagers](#triagers)
* [Release keys](#release-keys)
* [Quick Example](#quick-example)
* [License](#license)

## Support
Expand Down Expand Up @@ -136,6 +137,26 @@ source and a list of supported platforms.
For information on reporting security vulnerabilities in Node.js, see
[SECURITY.md](./SECURITY.md).

## Quick Example

Here's a simple HTTP server example that responds with "Hello World":

```javascript
const http = require('http');

const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});

server.listen(3000, '127.0.0.1', () => {
console.log('Server running at http://127.0.0.1:3000/');
});
```

Save this code to a file (e.g., `hello-world.js`) and run it with `node hello-world.js`.

## Contributing to Node.js

* [Contributing to the project][]
Expand Down