Skip to content
Snippets Groups Projects
Commit c8d0d524 authored by Xiao Gui's avatar Xiao Gui
Browse files

fix: add ready flag

parent a8fc561c
No related branches found
No related tags found
No related merge requests found
from pathlib import Path
from fastapi import FastAPI, Request
from fastapi.responses import RedirectResponse
from fastapi.responses import RedirectResponse, Response
from fastapi.staticfiles import StaticFiles
from starlette.middleware.sessions import SessionMiddleware
......@@ -13,9 +13,16 @@ from app.plugin import router as plugin_router
from app.auth import router as auth_router
from app.user import router as user_router
from app.config import HOST_PATHNAME
from app.logger import logger
app = FastAPI()
ready_flag = False
@app.get("/ready")
def ready():
return Response(None, 204 if ready_flag else 500)
app.add_middleware(SessionMiddleware, secret_key=SESSION_SECRET)
for vip_route in vip_routes:
......@@ -44,7 +51,9 @@ app.mount("/", StaticFiles(directory=Path(PATH_TO_PUBLIC)), name="static")
if HOST_PATHNAME:
assert HOST_PATHNAME[0] == "/", f"HOST_PATHNAME, if defined, must start with /: {HOST_PATHNAME!r}"
assert HOST_PATHNAME[-1] != "/", f"HOST_PATHNAME, if defined, must not end with /: {HOST_PATHNAME!r}"
logger.info(f"listening on path {HOST_PATHNAME}")
_app = app
app = FastAPI()
app.mount(HOST_PATHNAME, _app)
ready_flag = True
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment