Guest User

Untitled

a guest
Mar 25th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. var express = require('express');
  2. var cookieParser = require('cookie-parser');
  3. var bodyParser= require ('body-parser');
  4. var user = require('./routes/user');
  5. var login = require('./routes/login');
  6. var jwt = require('jsonwebtoken');
  7.  
  8. var app = express();
  9. app.use(bodyParser.json());
  10. app.use(cookieParser());
  11.  
  12.  
  13. app.get('/userprofile', user.getUserInfos);
  14. app.post('/users', user.createUser);
  15. app.get('/login', function (req, res) {
  16. var html='';
  17. html +="<body>";
  18. html += "<form action='/login' method='post' name='logingorm' enctype="application/json">";
  19. html += "Username:<input type= 'text' name='username'><br>";
  20. html += "Password:<input type='password' name='password'><br>";
  21. html += "<input type='submit' value='submit'>";
  22. html += "</form>";
  23. html += "</body>";
  24. res.send(html);
  25. });
  26. app.post('/login', user.login);
  27.  
  28.  
  29. app.listen(3000);
  30. console.log('Listening on port 3000...');
  31.  
  32. exports.login= function(req, res) {
  33. console.log(req.body);
  34. }
Add Comment
Please, Sign In to add comment