Basic HTTP Server

Basic HTTP Server

Medium NodeJS HTTP & APIs 33 views
Explanation Complexity

Problem Statement

Create an HTTP server that returns 'Hello meetcode'.

Input Format

No input.

Output Format

Start server code.

Constraints

Use built-in http module.

Input / Output Format

Input Format
No input.
Output Format
Start server code.
Constraints
Use built-in http module.

Example Solution (Public)

NodeJS
const http = require('http');

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

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

Official Solution Code

const http = require('http');

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

server.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.