node.js express web server code example
Example 1: express.js server
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("This is home page.");
});
app.post("/", (req, res) => {
res.send("This is home page with post request.");
});
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server is running on PORT: ${PORT}`);
});
Example 2: js express server
const http = require('http')
const express = require('express')
const app = express()
const server = http.Server(app)
app.set('port', 8888)
server.listen(8888)
app.get('/', (req, res) => {
res.json({teste: true})
})
Example 3: express js
Express.js, or simply Express, is a web application framework for Node.js,
released as free and open-source software under the MIT License.
It is designed for building web applications and APIs.
It has been called the de facto standard server framework for Node.js.
Example 4: what is express.js
Express is a minimal and flexible Node.js web application framework
that provides a robust set of features for web and mobile
applications.