Guest User

Untitled

a guest
Oct 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. // ===/ Dependencies ==========================================================
  2.  
  3. var express = require("express");
  4. var app = express.createServer();
  5.  
  6. app.configure( function() {
  7. app.use(express.logger());
  8. app.use(express.bodyParser());
  9. app.use(express.methodOverride());
  10. app.use(app.router);
  11. app.use(express.static(__dirname + '/public'));
  12. });
  13.  
  14. // ===/ Routes ================================================================
  15.  
  16. /* --------------------------------------------------------------------------
  17. * Root - redirect to /index.html
  18. * -------------------------------------------------------------------------- */
  19. app.get('/', function(req, res){
  20. console.log("[redirect] /index.html");
  21. res.redirect("/index.html");
  22. });
  23.  
  24.  
  25. /* --------------------------------------------------------------------------
  26. * Authenticate the user
  27. * -------------------------------------------------------------------------- */
  28. app.post('/profile/authenticate', function(req, res){
  29.  
  30. var body = req.body;
  31. console.log(body); /// <===================================================== req.body is always undefined
  32.  
  33. res.writeHeader(200, {'content-type' : 'text/plain'});
  34. res.write("hmm");
  35. res.end("\n");
  36. });
  37.  
  38.  
  39. // ===/ Startup ===============================================================
  40.  
  41.  
  42. app.listen(3000);
  43. console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
Add Comment
Please, Sign In to add comment