-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (29 loc) · 922 Bytes
/
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
const express = require('express');
const app = express();
const config = require('./config');
const path = require('path');
const axios = require('axios')
const port = config.port || 3000;
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/views'));
app.use(express.static(__dirname + '/public'));
app.get('/', async (req, res) => {
res.render('index', {
title: 'Home',
config: config
});
});
app.get('/tv/:ip', async (req, res) => {
res.render('tv', {
title: 'TV',
ip: req.params.ip,
});
})
app.get('/tv/:ip/post', async (req, res) => {
var ip = req.params.ip;
var command = req.query.command;
axios.post(`${config.api}/tv/${ip}`, { "command": command })
res.redirect(`/tv/${ip}`)
})
// Launch app on port
app.listen(port, () => console.log('\x1b[31m%s\x1b[0m', '[SERVER]', '\x1b[32m[WEB]\x1b[0m', `Connected @ localhost:${port}`));