-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (25 loc) · 1.01 KB
/
Copy pathapp.js
File metadata and controls
32 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var express = require('express');
var app = express();
var myLogger = function (req, res, next) {
let newDate = new Date(Date.now());
console.log(`${newDate.toDateString()} ${newDate.toTimeString()}` + " ::: " + req.path)
next()
}
// Our Middleware
app.use(myLogger)
// Middleware for accepting Content-Type: application/x-www-form-urlencoded
app.use(express.urlencoded())
// Middleware for accepting Content-Type: application/json
app.use(express.json())
// Imports of all different kind of routes
require("./src/routes/example")(app)
require("./src/routes/main")(app)
// Creates a server
var server = app.listen(8000, function () {
var host = server.address().address
var port = server.address().port
console.log("Application listening at http://%s:%s", host, port)
})
// We are going to use only post function
// curl -XPOST localhost:8000 -d '{"User": "sid573", "Project": "M-Omics"}'
// curl -XPOST localhost:8000 -H "Content-Type: application/json" -d ' {"User": "sid573", "Project": "M-Omics"} '