-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptoServer.js
More file actions
30 lines (25 loc) · 759 Bytes
/
Copy pathcryptoServer.js
File metadata and controls
30 lines (25 loc) · 759 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
const express = require('express');
const app = express();
const port = 8080;
const bodyParser = require('body-parser')
var urlencodedParser = bodyParser.urlencoded({ extended: false })
app.get('/', (req, res) => {
res.send(`Hello World !!`)
})
app.post('/login', urlencodedParser, function (req, res) {
const { username ,password } = req.body
if (username === 'admin' && password === 'admin') {
return res.json({
'status': 'ok',
'message': 'adminToken123'
})
} else {
return res.json({
'status': 'error',
'message': 'Incorrect username or password'
})
}
})
app.listen( port, () => {
console.log(`Server running at http://localhost:${port}`);
});