From a63048d3131b54dcf3b45e5730a2e52449300e00 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 00:53:32 +0000 Subject: [PATCH 1/2] Initial plan From 457a98875f4e11b5abbbe868172854f5f1c0f38f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 00:59:46 +0000 Subject: [PATCH 2/2] Address code review feedback: cache template, add error handling, make sync Co-authored-by: jbouder <61591423+jbouder@users.noreply.github.com> --- app/main.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index c0ed2cc..7c086e3 100644 --- a/app/main.py +++ b/app/main.py @@ -35,13 +35,30 @@ Base.metadata.create_all(bind=engine) logger.info("Database tables created") +# Load and cache the landing page template at startup +_landing_page_template: str | None = None +try: + html_path = Path(__file__).parent / "templates" / "index.html" + _landing_page_template = html_path.read_text() + logger.info("Landing page template loaded successfully") +except Exception as e: + logger.error("Failed to load landing page template from %s: %s", html_path, e) + # Root endpoint with API documentation links @app.get("/", response_class=HTMLResponse, include_in_schema=False) -async def root(): +def root(): """Render an HTML page with links to API documentation.""" - html_path = Path(__file__).parent / "templates" / "index.html" - return html_path.read_text() + if _landing_page_template is None: + logger.error("Landing page template not available") + return HTMLResponse( + content=( + "Error: Unable to load the homepage template. " + "Please contact the administrator." + ), + status_code=500, + ) + return _landing_page_template # Add routes