Guest User

server

a guest
Jul 13th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express');
  2. var app = express();
  3. var bodyParser = require('body-parser');
  4. app.use(express.static('public'));
  5. app.use( bodyParser.json() );       // to support JSON-encoded bodies
  6. app.use(bodyParser.urlencoded({     // to support URL-encoded bodies
  7.   extended: true
  8. }));
  9. app.get('/index.htm', function (req, res) {
  10.    res.sendFile( __dirname + "/" + "index.htm" );
  11. })
  12. app.post('/ajaxTarget', function (req, res) {
  13.     console.log(req.body);
  14. });
  15.  
  16. var server = app.listen(8081, function () {
  17.   var host = server.address().address
  18.   var port = server.address().port
  19.   console.log("Example app listening at http://%s:%s", host, port)
  20. });
Advertisement
Add Comment
Please, Sign In to add comment