Repository navigation
Fix initial page rendering - #4
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
Internal Server Erroron Render when loading/and makes homepage template loading robust across source and packaged deployments.This MR also updates packaging so the styled homepage template is always included in built artifacts (
wheel/sdist), and keeps a single template source of truth atapp/templates/index.html.Problem
The root page (
/) could fail in hosted environments (Render) withTemplateNotFound, causing HTTP 500.Root Cause
Template path resolution was tied to repository layout assumptions. In packaged/runtime environments, template files may live under installed package paths, not the repo root.
What Changed
1. Resilient template directory resolution
_resolve_template_directories()inapp/main.pyto search multiple locations:<repo>/templates<site-packages>/app/templates<cwd>/templatesJinja2Templatesnow uses discovered existing directories.2. Safe fallback for missing template
try/except TemplateNotFound./docs/redoc/health/in degraded template scenarios.3. Packaging fixes for template inclusion
pyproject.toml:include-package-data = true[tool.setuptools.packages.find] include = ["app*"]app = ["templates/*.html"]app/templates/index.htmlis included inwheel/sdist.4. Single source of truth for homepage template
templates/index.htmltoapp/templates/index.html.5. Regression test coverage
/still returns200when template loading raisesTemplateNotFound.Files Changed
app/main.pypyproject.tomlapp/templates/index.html(moved fromtemplates/index.html)tests/test_api.pyValidation
Executed targeted tests:
tests/test_api.py::test_home_page_endpointtests/test_api.py::test_home_page_endpoint_falls_back_when_template_missingResult: both passed.
Also validated package artifact contents during development:
app/templates/index.htmlpresent in builtwheel/sdist.appsubpackages included correctly via package discovery.Impact
Rollback Plan