Skip to content

Instantly share code, notes, and snippets.

View rajasekar-d's full-sized avatar
💭
I may be slow to respond.

Rajasekar D rajasekar-d

💭
I may be slow to respond.
View GitHub Profile
const http = require('http');
const PORT = 4000;
const server = http.createServer((req, res) => {
res.setHeader('Content-Type', 'application/json');
const fullUrl = `http://${req.headers.host}${req.url}`;
console.log(`[${req.method}] ${fullUrl}`);
switch (req.method) {
case 'GET':
res.writeHead(200);