更新config文件,添加orm
This commit is contained in:
parent
43da7d5bef
commit
b2db8b8574
1
model.py
1
model.py
@ -60,6 +60,7 @@ class SioConfig(BaseModel):
|
||||
client_id: str
|
||||
client_secret: str
|
||||
localhost: str
|
||||
db_url: str
|
||||
|
||||
|
||||
@dataclass
|
||||
|
10
server.py
10
server.py
@ -6,6 +6,7 @@ from sanic import Sanic, Request
|
||||
from sanic.log import logger, Colors
|
||||
from sanic.response import text
|
||||
from socketio import AsyncClient
|
||||
from tortoise.contrib.sanic import register_tortoise
|
||||
|
||||
from command import command_convert
|
||||
from gitea_model import WebHookIssueComment, WebHookIssue, GiteaEvent
|
||||
@ -21,9 +22,16 @@ def get_config() -> SioConfig:
|
||||
return SioConfig(**config)
|
||||
|
||||
|
||||
SIO_CONFIG = get_config()
|
||||
|
||||
register_tortoise(
|
||||
app, db_url=SIO_CONFIG.db_url, modules={"models": ["orm"]}, generate_schemas=True
|
||||
)
|
||||
|
||||
|
||||
@app.before_server_start
|
||||
async def setup_before_start(_app):
|
||||
_app.ctx.sio_config = get_config()
|
||||
_app.ctx.sio_config = SIO_CONFIG
|
||||
_app.ctx.sio = AsyncClient()
|
||||
|
||||
start_sio_listener()
|
||||
|
Loading…
Reference in New Issue
Block a user