Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var cookieParser = require('cookie-parser');
- var bodyParser= require ('body-parser');
- var user = require('./routes/user');
- var login = require('./routes/login');
- var jwt = require('jsonwebtoken');
- var app = express();
- app.use(bodyParser.json());
- app.use(cookieParser());
- app.get('/userprofile', user.getUserInfos);
- app.post('/users', user.createUser);
- app.get('/login', function (req, res) {
- var html='';
- html +="<body>";
- html += "<form action='/login' method='post' name='logingorm' enctype="application/json">";
- html += "Username:<input type= 'text' name='username'><br>";
- html += "Password:<input type='password' name='password'><br>";
- html += "<input type='submit' value='submit'>";
- html += "</form>";
- html += "</body>";
- res.send(html);
- });
- app.post('/login', user.login);
- app.listen(3000);
- console.log('Listening on port 3000...');
- exports.login= function(req, res) {
- console.log(req.body);
- }
Add Comment
Please, Sign In to add comment