-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathws.js
More file actions
executable file
·36 lines (29 loc) · 871 Bytes
/
ws.js
File metadata and controls
executable file
·36 lines (29 loc) · 871 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
26
27
28
29
30
31
32
33
34
35
36
var sys = require('sys')
, http = require('http')
, restify = require('restify')
, fs = require('fs')
, cfg = require('./config.json')
, formidable = require('formidable')
, util = require('util')
, path = require('path')
, mime = require('mime')
, sqlite3 = require("sqlite3").verbose()
, pg = require('pg')
;
// EXPOSED WEB SERVICES
function index(req, res, next) {
fs.readFile('html/index.htm', {encoding : "UTF-8"}, function (err, html) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(html);
});
}
// INTERNAL FUNCTIONS
var server = restify.createServer();
server.use(restify.bodyParser())
server.get('/', index);
server.pre(restify.CORS({
credentials: true
}));
server.listen(cfg['ws_port'], function() {
console.log("(ws.js) server running on port " + cfg['ws_port']);
});