You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
TrashSensor_API/server.js

32 lines
862 B

const util = require('util');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 3001;
const logging = (req, res, next) => {
var ip = req.ip;
console.log("------------------------------------------------------------");
const curData = new Date();
//console.log(curData.toISOString())
console.log(curData.toLocaleString("ru-RU", { timeZone: process.env.TZ }))
console.log('Request from', ip);
console.log(`Request received for ${req.method} ${req.url}`);
console.log(`Request body: ${util.inspect(req.body)}`);
next();
};
app.use(bodyParser.urlencoded({ extended: true }));
app.use(logging);
app.get('/', (req, res) => {
res.send('OK TEST');
});
app.listen(port, '0.0.0.0', () => {
console.log(`Server is running on http://localhost:${port}`);
});