Init
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
from ..Convention.Runtime.Config import *
|
||||
from ..Convention.Runtime.GlobalConfig import ProjectConfig, ConsoleFrontColor
|
||||
from ..CoreModules.flags import set_internal_verbose
|
||||
from ..CoreModules.flags import set_internal_verbose, get_internal_debug
|
||||
from .web import app
|
||||
from argparse import ArgumentParser
|
||||
from typing import *
|
||||
import sys
|
||||
import uvicorn
|
||||
try:
|
||||
import uvicorn
|
||||
except ImportError as ex:
|
||||
ImportingThrow(ex, "Internal", ["uvicorn"])
|
||||
|
||||
def main() -> int:
|
||||
config = ProjectConfig()
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("--main-webhook-url", type=str, default=config.FindItem("main_webhook_url", ""))
|
||||
parser.add_argument("--host", type=str, default=config.FindItem("host", "0.0.0.0"))
|
||||
parser.add_argument("--port", type=int, default=config.FindItem("port", 8000))
|
||||
parser.add_argument("--verbose", type=bool, default=config.FindItem("verbose", False))
|
||||
@@ -22,17 +25,6 @@ def main() -> int:
|
||||
parser.print_help()
|
||||
return 0
|
||||
|
||||
# region Main Webhook URL
|
||||
|
||||
webhook_url = args.main_webhook_url
|
||||
if not webhook_url or webhook_url == "":
|
||||
config.Log("Fatal", f"{ConsoleFrontColor.RED}Main webhook URL is not set{ConsoleFrontColor.RESET}")
|
||||
return 1
|
||||
|
||||
config.Log("Info", f"{ConsoleFrontColor.GREEN}Main webhook URL: {webhook_url}{ConsoleFrontColor.RESET}")
|
||||
|
||||
# endregion Main Webhook URL
|
||||
|
||||
# region Verbose
|
||||
|
||||
verbose = args.verbose
|
||||
|
||||
@@ -4,7 +4,7 @@ from fastapi.responses import JSONResponse
|
||||
from contextlib import asynccontextmanager
|
||||
from ..CoreModules.middleware import ConcurrencyLimitMiddleware
|
||||
from ..CoreModules.plugin_interface import ImportPlugins
|
||||
from ..CoreRouters import callback, health, private
|
||||
from ..CoreRouters import callback, health
|
||||
from ..Convention.Runtime.GlobalConfig import *
|
||||
from ..Convention.Runtime.Architecture import Architecture
|
||||
|
||||
@@ -46,8 +46,7 @@ def generate_app(APP_CONFIG: dict) -> FastAPI:
|
||||
# 注册路由
|
||||
app.include_router(callback.router, prefix="/api", tags=["callback"])
|
||||
app.include_router(health.router, tags=["health"])
|
||||
app.include_router(private.router, prefix="/api", tags=["private"])
|
||||
ImportPlugins(app, config.FindItem("plugin_dir", "Plugins"))
|
||||
ImportPlugins(app, config.FindItem("plugin_dir", "Plugins/"))
|
||||
|
||||
# 注册至框架中
|
||||
Architecture.Register(FastAPI, app, lambda: None)
|
||||
|
||||
Reference in New Issue
Block a user