feat: finish forecast rendering and account-authenticated API explorer
This commit is contained in:
@@ -891,7 +891,7 @@ def create_app(settings=None, start_worker=True):
|
||||
|
||||
@app.get("/docs", include_in_schema=False)
|
||||
def api_docs():
|
||||
return get_swagger_ui_html(
|
||||
response = get_swagger_ui_html(
|
||||
openapi_url="/openapi.json",
|
||||
title="Pigway Frame Flow · API Docs",
|
||||
swagger_js_url="/ui/swagger-ui-bundle.js",
|
||||
@@ -902,6 +902,24 @@ def create_app(settings=None, start_worker=True):
|
||||
"displayRequestDuration": True,
|
||||
},
|
||||
)
|
||||
html = (
|
||||
bytes(response.body)
|
||||
.decode()
|
||||
.replace(
|
||||
"SwaggerUIBundle({",
|
||||
"""SwaggerUIBundle({
|
||||
requestInterceptor: async (req) => {
|
||||
if (!['GET','HEAD'].includes(req.method.toUpperCase())) {
|
||||
const session = await fetch('/api/v1/auth/me');
|
||||
if (session.ok) req.headers['X-CSRF-Token'] = (await session.json()).csrf_token;
|
||||
}
|
||||
return req;
|
||||
},""",
|
||||
)
|
||||
)
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
return HTMLResponse(html)
|
||||
|
||||
root = Path(__file__).resolve().parent.parent / "web"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user