From 77a27163ae48fdb8128c496e4a98bf6f67036bd6 Mon Sep 17 00:00:00 2001 From: Ronitkumar Sabhaya Date: Tue, 13 May 2025 09:23:44 -0500 Subject: [PATCH] Added a simple HTTP server example to the README.md to showcase basic Node.js functionality. --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index dcb1e77c5d9477..79901fc57605f9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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][]