mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-08 14:56:03 +00:00
perf: 首页展示版本信息
This commit is contained in:
@@ -54,7 +54,7 @@ class RouterGroup(abc.ABC):
|
||||
return self.http_status(500, -2, str(e))
|
||||
|
||||
new_f = handler_error
|
||||
new_f.__name__ = f.__name__
|
||||
new_f.__name__ = (self.name + rule).replace('/', '__')
|
||||
new_f.__doc__ = f.__doc__
|
||||
|
||||
self.quart_app.route(rule, **options)(new_f)
|
||||
|
||||
19
pkg/api/http/controller/groups/system.py
Normal file
19
pkg/api/http/controller/groups/system.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import quart
|
||||
|
||||
from .....core import app
|
||||
from .. import group
|
||||
from .....utils import constants
|
||||
|
||||
|
||||
@group.group_class('system', '/api/v1/system')
|
||||
class SystemRouterGroup(group.RouterGroup):
|
||||
|
||||
async def initialize(self) -> None:
|
||||
@self.route('/info', methods=['GET'])
|
||||
async def _() -> str:
|
||||
return self.success(
|
||||
data={
|
||||
"version": constants.semantic_version,
|
||||
"debug": constants.debug_mode
|
||||
}
|
||||
)
|
||||
@@ -5,7 +5,7 @@ import asyncio
|
||||
import quart
|
||||
|
||||
from ....core import app
|
||||
from .groups import logs
|
||||
from .groups import logs, system
|
||||
from . import group
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ from __future__ import print_function
|
||||
|
||||
import traceback
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from . import app
|
||||
from ..audit import identifier
|
||||
from . import stage
|
||||
from ..utils import constants
|
||||
|
||||
# 引入启动阶段实现以便注册
|
||||
from .stages import load_config, setup_logger, build_app, migrate, show_notes
|
||||
@@ -25,6 +27,10 @@ async def make_app(loop: asyncio.AbstractEventLoop) -> app.Application:
|
||||
# 生成标识符
|
||||
identifier.init()
|
||||
|
||||
# 确定是否为调试模式
|
||||
if "DEBUG" in os.environ and os.environ["DEBUG"] in ["true", "1"]:
|
||||
constants.debug_mode = True
|
||||
|
||||
ap = app.Application()
|
||||
|
||||
ap.event_loop = loop
|
||||
|
||||
@@ -5,6 +5,8 @@ import time
|
||||
|
||||
import colorlog
|
||||
|
||||
from ...utils import constants
|
||||
|
||||
|
||||
log_colors_config = {
|
||||
"DEBUG": "green", # cyan white
|
||||
@@ -22,7 +24,7 @@ async def init_logging(extra_handlers: list[logging.Handler] = None) -> logging.
|
||||
|
||||
level = logging.INFO
|
||||
|
||||
if "DEBUG" in os.environ and os.environ["DEBUG"] in ["true", "1"]:
|
||||
if constants.debug_mode:
|
||||
level = logging.DEBUG
|
||||
|
||||
log_file_name = "data/logs/qcg-%s.log" % time.strftime(
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
semantic_version = "v3.3.1.1"
|
||||
|
||||
debug_mode = False
|
||||
Reference in New Issue
Block a user