-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.py
48 lines (38 loc) · 1.39 KB
/
main.py
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
import asyncio
import logging
import os
import sys
from tornado.web import Application, RequestHandler, StaticFileHandler
from common.config import getConfig
from controller import systemController, jobController, notifyController
from service.system import onStart
class MainIndex(RequestHandler):
def get(self):
self.render(os.path.join(frontendPath, "front/index.html"))
def make_app():
# 以/svr/noAuth开头的请求无需鉴权,例如登录等
return Application([
(r"/svr/noAuth/login", systemController.Login),
(r"/svr/user", systemController.User),
(r"/svr/language", systemController.Language),
(r"/svr/alist", jobController.Alist),
(r"/svr/job", jobController.Job),
(r"/svr/notify", notifyController.Notify),
(r"/", MainIndex),
(r"/(.*)", StaticFileHandler,
{"path": os.path.join(frontendPath, "front")})
], cookie_secret=server['passwdStr'])
async def main():
app = make_app()
logger = logging.getLogger()
app.listen(server['port'])
successMsg = f"启动成功_/_Running at http://127.0.0.1:{server['port']}/"
logger.critical(successMsg)
await asyncio.Event().wait()
if __name__ == "__main__":
onStart.init()
cfg = getConfig()
frontendPath = sys._MEIPASS if getattr(sys, 'frozen', False) else '.'
# 后端配置
server = cfg['server']
asyncio.run(main())