-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (24 loc) · 840 Bytes
/
app.js
File metadata and controls
34 lines (24 loc) · 840 Bytes
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
import http from 'http'
import { automateFunction } from './automate/automate.js';
import express from 'express'
import bodyParser from 'body-parser';
import cors from 'cors'
const hostname = "127.0.0.1";
const port = 8000;
const app = express()
app.use(cors({ origin: "*" }));
const urlencodedParser = bodyParser.urlencoded({ extended: false });
const jsonParser = bodyParser.json();
app.post('/', urlencodedParser, function(req, res) {
res.send(req.body)
})
app.post("/json", jsonParser, function (req, res) {
if(req.body.email && req.body.password) {
const response = automateFunction(req.body.email, req.body.password)
// console.log(response)
if(response == "error") res.send({"respnse": "error"})
else if(response == "success") res.send({"response": "success"})
}
});
app.listen(port, () => {
});