from fastapi import APIRouter, Request from fastapi.openapi.docs import get_swagger_ui_html from fastapi.responses import HTMLResponse, Response router = APIRouter() @router.get("/.well-known/appspecific/com.chrome.devtools.json", include_in_schema=False) async def chrome_devtools_probe() -> Response: """Chrome DevTools probes this path whenever DevTools opens. Return an empty 204 so it doesn't show as a 404 in the access log.""" return Response(status_code=204) @router.get("/api/docs", include_in_schema=False) async def swagger_ui_dark(request: Request) -> HTMLResponse: base = get_swagger_ui_html( openapi_url=request.app.openapi_url, title="Recon Ranger — API Docs", swagger_js_url="/static/api/swagger-ui-bundle.js", swagger_css_url="/static/api/swagger-ui.css", swagger_favicon_url="/static/api/favicon.png", ) html = base.body.decode() html = html.replace( "", ( '\n' '\n' "\n" "" ), ) nav_html = """
""" html = html.replace("", "" + nav_html) html = html.replace("", "
") return HTMLResponse(html)