-
Notifications
You must be signed in to change notification settings - Fork 16
/
app.ts
34 lines (28 loc) · 1009 Bytes
/
app.ts
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
import request = require('request');
import express = require('express');
import cookieParser = require('cookie-parser');
import bodyParser = require('body-parser');
import bilibili = require('./src/bilibili');
import login = require('./src/login');
import website = require('./src/website_apis')
var app = express();
app.set('view engine', 'ejs');
let RootDir = __dirname + "/.."
app.use('/', express.static(RootDir + '/html'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/', function (req, res) {
res.render(RootDir + '/html/index.html.ejs');
});
app.get('*.html', function (req, res) {
res.render(RootDir + '/html' + req.url + ".ejs", function (err: Error, html: string) {
if(!err) res.send(html);
else {res.status(404); res.send("Page Not Found."); }
});
});
login.registerApis(app);
bilibili.registerApis(app);
website.registerApis(app);
var server = app.listen(8000)
console.log("Server started.")