Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // npm install express
- // npm install body-parser
- var express = require('express');
- var bodyParser = require('body-parser')
- var app = express();
- app.use(bodyParser.urlencoded({ extended: false }));
- app.post('/login', function (req, res) {
- if (!req.body.username || !req.body.password) {
- res.end( JSON.stringify({"status": "error", "message": "Parameter missed"}) );
- }
- if (req.body.username == 'admin' || req.body.password == 'password') {
- res.end( JSON.stringify({"status": "success", "token": Math.round(Math.random() * 99999)}) );
- } else {
- res.end( JSON.stringify({"status": "error", "message": "Access denied"}) );
- }
- })
- app.listen(8081);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement