-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
74 lines (59 loc) · 2.04 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
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
63
64
65
66
67
68
69
70
71
72
73
74
/**
* ____ __________
* / __ \_ _____ _____/ __/ / __ \_ __
* / / / / | / / _ \/ ___/ /_/ / / / / | /| / /
* / /_/ /| |/ / __/ / / __/ / /_/ /| |/ |/ /
* \____/ |___/\___/_/ /_/ /_/\____/ |__/|__/
*
* The copyright indication and this authorization indication shall be
* recorded in all copies or in important parts of the Software.
*
* @github https://github.com/0verfl0w767
*
*/
const express = require('express')
const fs = require('fs')
const http = require('http')
const app = express()
// app.get('/', (req, res) => {
// res.status(200).sendFile(__dirname + '/page/index.html')
// })
app.use('/', express.static(__dirname + '/public'))
app.get('/testLogin', (req, res) => {
res.status(200).sendFile(__dirname + '/page/testLogin.html')
})
app.get('/test1', (req, res) => {
res.status(200).sendFile(__dirname + '/page/test1.html')
})
app.get('/test2', (req, res) => {
res.status(200).sendFile(__dirname + '/page/test2.html')
})
app.get('/basket', (req, res) => {
res.status(200).sendFile(__dirname + '/page/basket.html')
})
app.get('/closed', (req, res) => {
res.status(200).sendFile(__dirname + '/page/closed.html')
})
app.get('/warning', (req, res) => {
res.status(200).sendFile(__dirname + '/page/warning.html')
})
app.get('/api/basket', (req, res) => {
const jsonData = JSON.parse(fs.readFileSync(__dirname + '/convert0.json', 'utf8'))
res.status(200).json(jsonData)
})
app.get('/api/live', (req, res) => {
const jsonData = JSON.parse(fs.readFileSync(__dirname + '/convert1.json', 'utf8'))
res.status(200).json(jsonData)
})
app.get('/api/closed', (req, res) => {
const jsonData = JSON.parse(fs.readFileSync(__dirname + '/convert3.json', 'utf8'))
res.status(200).json(jsonData)
})
app.get('/api/warning', (req, res) => {
const jsonData = JSON.parse(fs.readFileSync(__dirname + '/convert4.json', 'utf8'))
res.status(200).json(jsonData)
})
app.get('*', (req, res) => {
res.status(404).json({statusCode: 404, message: 'unknown request.'})
})
http.createServer(app).listen(4646, '0.0.0.0')