javascript node server code example
Example 1: how to create node js server
//HTTP MODULE NODE.JS
var http = require('http');
var server = http.createServer(function(req, res){
//write code here
});
server.listen(5000);
Example 2: create node js server
import express from 'express';
const server = express();
const port = 8080;
server.get('/', (req, res) => {
return res.send('Hello, Express.js!');
})
server.listen(port, () => {
console.log(`Server is running on port ${port}`);
});