express and node pakages

Solutions on MaxInterview for express and node pakages by the best coders in the world

showing results for - "express and node pakages"
Maja
23 May 2020
1var express = require('express');
2var app = express();
3
4// This responds with "Hello World" on the homepage
5app.get('/', function (req, res) {
6   console.log("Got a GET request for the homepage");
7   res.send('Hello GET');
8})
9
10// This responds a POST request for the homepage
11app.post('/', function (req, res) {
12   console.log("Got a POST request for the homepage");
13   res.send('Hello POST');
14})
15
16// This responds a DELETE request for the /del_user page.
17app.delete('/del_user', function (req, res) {
18   console.log("Got a DELETE request for /del_user");
19   res.send('Hello DELETE');
20})
21
22// This responds a GET request for the /list_user page.
23app.get('/list_user', function (req, res) {
24   console.log("Got a GET request for /list_user");
25   res.send('Page Listing');
26})
27
28// This responds a GET request for abcd, abxcd, ab123cd, and so on
29app.get('/ab*cd', function(req, res) {   
30   console.log("Got a GET request for /ab*cd");
31   res.send('Page Pattern Match');
32})
33
34var server = app.listen(8081, function () {
35   var host = server.address().address
36   var port = server.address().port
37   
38   console.log("Example app listening at http://%s:%s", host, port)
39})
Stefano
02 Jan 2019
1var express = require('express');
2var app = express();
3
4app.use(express.static('public'));
5
6app.get('/', function (req, res) {
7   res.send('Hello World');
8})
9
10var server = app.listen(8081, function () {
11   var host = server.address().address
12   var port = server.address().port
13
14   console.log("Example app listening at http://%s:%s", host, port)
15})
Maximilian
21 Aug 2016
1var express = require('express');
2var app = express();
3
4app.get('/', function (req, res) {
5   res.send('Hello World');
6})
7
8var server = app.listen(8081, function () {
9   var host = server.address().address
10   var port = server.address().port
11   
12   console.log("Example app listening at http://%s:%s", host, port)
13})