xxxxxxxxxx
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
xxxxxxxxxx
// Load HTTP module
const http = require("http");
const hostname = "127.0.0.1";
const port = 8000;
// Create HTTP server
const server = http.createServer((req, res) => {
// Set the response HTTP header with HTTP status and Content type
res.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body "Hello World"
res.end('Hello World\n');
});
// Prints a log once the server starts listening
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
})
xxxxxxxxxx
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World!')
});
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`)
});
xxxxxxxxxx
Express is a minimal and flexible Node.js web application framework
that provides a robust set of features for web and mobile
applications.
xxxxxxxxxx
If you are looking for simplier NodeJS express is on the go choice for you.
expressJS is:
> NodeJS framework
> Free to use
USES = ['twitter', 'paypal', 'yandex', 'bbc', 'sohu', 'and so on.']
How to install?
Open your console and write the following commands
xxxxxxxxxx
mkdir name
cd name
npm init -y
npm i express cors dotenv mongodb
Added by: Md. Imrul Kayes