aboutsummaryrefslogtreecommitdiff
path: root/src/webui.js
blob: 8a9fa56c057b5142c5776350f8c65c86e19c04b9 (plain)
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

const key = process.env.WEBUI_KEY
const bodyParser = require("body-parser");
const express = require('express');
let db = require("../src/db");
const path = require("path")
const Tickets = db.Tickets

const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const port = 7001;
app.get('/tickets', async (req, res) => {
  res.sendFile(path.join(__dirname+'/../html/tickets.html'))
})
app.post('/tickets/data', async (req, res) => {
  if(req.body.key == key)
    res.send(await Tickets.findAll())
  else
    res.send('failed')
})
app.post('/tickets/edit', async (req, res) => {
  if(req.body.key == key){
    console.log('pass')
		res.send('pass')
  }
  else
    res.send('failed')
})

app.get('/settings', async (req, res) => {
  res.sendFile(path.join(__dirname+'/../html/settings.html'))
})
app.post('/settings/data', async (req, res) => {
  if(req.body.key == key)
    res.send('todo:P')
  else
    res.send('failed')
})
app.listen(port, () => console.log(`listening at http://localhost:${port}`));