-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (34 loc) · 962 Bytes
/
index.js
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
33
34
35
36
37
38
39
const { json } = require('express');
const express = require('express');
const app = express();
app.use(express.json());
//Handling Get request for / URI
app.get('/', (req, res) => {
res.send('Express App Running 1236');
});
app.get('/time',(req,res) => {
const time = new Date();
res.send(time);
});
app.post('/testPostMan', (req, res) => {
res.send("Hello");
});
app.get('/testPostManGetVariables', (req, res) => {
const tempVariable = req.query.temp;
res.send("Hello " + tempVariable);
});
app.get('/recordTemp', (req,res) => {
const temp = req.query.temp || 0;
if(temp >= 100)
{
res.send("Your Temp is grater than 100");
}else{
res.send("Your temp is lesser than 100");
}
});
app.post('/handleJson', (req,res) => {
res.send(req.body.name);
});
//Deploying the listener
const port = process.env.PORT || 8081;
app.listen(port, () => console.log(`Express server listening on port ${port}`));