-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
78 lines (65 loc) · 1.61 KB
/
server.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Write your server code in this file. Don't forget to add your name and
* @oregonstate.edu email address below.
*
* name: Ashyan Rahavi
* email: rahavia@oregonstate.edu
*/
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var socketIO = require('socket.io');
var urlencodedParser = bodyParser.urlencoded({extended: true});
async function myTimer() {
console.log('This prints every second');
}
//setInterval(myTimer, 1000);
app.use(function (req, res, next) {
console.log("== Request made");
console.log(" - Method:", req.method);
console.log(" - URL:", req.url);
next();
});
/*
app.get("/", function(req, res, next) {
res.type('text/html');
res.send(indexPage);
});
app.get("/index.html", function(req, res, next) {
res.type('text/html');
res.send(indexPage);
});
app.get("/style.css", function(req, res, next) {
res.type('text/css');
res.send(cssStyle);
});
app.get("/index.js", function(req, res, next) {
res.type('application/javascript');
res.send(indexJS);
});
*/
app.use(express.static('public'));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.post("/update-text*", function(req, res, next) {
console.log('test');
console.log(req.body);
});
app.get("*", function(req, res, next) {
res.type('text/html');
res.status(404).send(page404);
});
var port = process.env.PORT;
if(!port) {
port = 3000;
}
app.listen(port, function(err) {
if(err) {
throw err;
}
console.log('Server is listening on port', port);
});
io.on('connection', function(socket) {
});