-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.js
More file actions
25 lines (18 loc) · 674 Bytes
/
web.js
File metadata and controls
25 lines (18 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var express = require('express');
var fs = require('fs');
var app = express.createServer(express.logger());
/* var app = express.createServer();*/
app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());
var buffer = fs.readFileSync("index.html");
var myString = buffer.toString("utf-8");
app.get('/', function(request, response) {
response.send(myString);
});
app.post('/myaction', function(req, res) {
res.send('You sent the values: "' + req.body.user.name + '"as username, and "' + req.body.user.email + '"as useremail.');
});
var port = process.env.PORT || 8080;
app.listen(port, function() {
console.log("Listening on " + port);
});