forked from msloth/lgtv.js
-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.js
36 lines (30 loc) · 1.02 KB
/
index.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
var express = require('express')
var app = express()
var bodyParser = require('body-parser');
var fs = require('fs');
try {
var CONFIG = require('./config')
} catch (e) {
fs.writeFile("config.json", '{"lgtvip" : "0.0.0.0", "lgtvmac" : "00:00:00:00:00:00"}', function(err) {
if(err) {
return console.log(err);
}
console.log("Config file created");
});
} finally {
console.log(CONFIG);
}
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.use(express.static('public'))
app.get('/', function(req, res, next) {
res.type('html').sendFile(__dirname + '/index.html');
});
app.use('/input', require('./apis/change-input'));
app.use('/volume', require('./apis/change-volume'));
app.use('/alert', require('./apis/alert'));
app.use('/off', require('./apis/turn-off'));
app.use('/on', require('./apis/turn-on'));
app.listen(5555, function () {
console.log('LGTV http server is up in http://localhost:5555')
})