2019-06-12 13:55:49 +08:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
import tornado.web
|
|
|
|
|
|
2020-02-06 19:51:03 +08:00
|
|
|
|
import api.base
|
|
|
|
|
import config
|
|
|
|
|
import update
|
|
|
|
|
|
2019-06-12 13:55:49 +08:00
|
|
|
|
|
2022-02-15 00:18:46 +08:00
|
|
|
|
class MainHandler(tornado.web.StaticFileHandler): # noqa
|
2020-08-18 21:48:33 +08:00
|
|
|
|
"""为了使用Vue Router的history模式,把不存在的文件请求转发到index.html"""
|
|
|
|
|
async def get(self, path, include_body=True):
|
|
|
|
|
try:
|
|
|
|
|
await super().get(path, include_body)
|
|
|
|
|
except tornado.web.HTTPError as e:
|
|
|
|
|
if e.status_code != 404:
|
|
|
|
|
raise
|
|
|
|
|
# 不存在的文件请求转发到index.html,交给前端路由
|
|
|
|
|
await super().get('index.html', include_body)
|
2020-02-06 19:51:03 +08:00
|
|
|
|
|
|
|
|
|
|
2022-02-15 00:18:46 +08:00
|
|
|
|
class ServerInfoHandler(api.base.ApiHandler): # noqa
|
2020-02-06 19:51:03 +08:00
|
|
|
|
async def get(self):
|
|
|
|
|
cfg = config.get_config()
|
|
|
|
|
self.write({
|
|
|
|
|
'version': update.VERSION,
|
|
|
|
|
'config': {
|
2020-08-30 17:46:04 +08:00
|
|
|
|
'enableTranslate': cfg.enable_translate,
|
|
|
|
|
'loaderUrl': cfg.loader_url
|
2020-02-06 19:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
})
|