mirror of
https://github.com/qwerfd2/OverRide-Server.git
synced 2026-09-26 00:38:01 +03:00
Update 5002.py
This commit is contained in:
+8
-7
@@ -2,6 +2,7 @@ from starlette.applications import Starlette
|
||||
from starlette.responses import FileResponse, Response, JSONResponse
|
||||
from starlette.routing import Route
|
||||
from starlette.requests import Request
|
||||
import contextlib
|
||||
import os
|
||||
import databases
|
||||
import sqlalchemy
|
||||
@@ -393,16 +394,16 @@ routes = [
|
||||
|
||||
routes.append(Route("/{path:path}", serve_file))
|
||||
|
||||
app = Starlette(debug=DEBUG, routes=routes)
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
@contextlib.asynccontextmanager
|
||||
async def lifespan(app: Starlette):
|
||||
await database.connect()
|
||||
await init_db()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
await database.disconnect()
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown():
|
||||
await database.disconnect()
|
||||
app = Starlette(debug=DEBUG, routes=routes, lifespan=lifespan)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
Reference in New Issue
Block a user