-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
62 lines (50 loc) · 1.19 KB
/
app.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
/*
* Module dependencies
*/
var express = require('express')
, stylus = require('stylus')
, nib = require('nib')
, net = require('net')
var app = express()
function compile(str, path) {
return stylus(str)
.set('filename', path)
.use(nib())
}
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))
app.use(stylus.middleware(
{ src: __dirname + '/public'
, compile: compile
}
))
app.use(express.static(__dirname + '/public'))
// UDP Socket Server
var dgram = require("dgram");
var server = dgram.createSocket("udp4");
var buffer = ''
server.on("error", function (err) {
console.log("server error:\n" + err.stack);
server.close();
});
server.on("message", function (msg, rinfo, res) {
console.log("server got: " + msg + " from " +
rinfo.address + ":" + rinfo.port);
buffer = msg;
// res.write({data:buffer});
});
server.on("listening", function () {
var address = server.address();
console.log("server listening " +
address.address + ":" + address.port);
});
server.bind(8888);
// Render
app.get('/', function (req, res) {
res.render('index',
{ title : 'Home' ,
data : buffer}
);
});
app.listen(3000)