Restore home page with README display

Instead of redirecting to /runs, show the home page with stats and README.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-01-11 12:54:50 +00:00
parent a34fff3aaa
commit f0db4f4ea6
2 changed files with 26 additions and 7 deletions

View File

@@ -2,6 +2,9 @@
Home and root routes for L1 server. Home and root routes for L1 server.
""" """
from pathlib import Path
import markdown
from fastapi import APIRouter, Request, Depends from fastapi import APIRouter, Request, Depends
from fastapi.responses import HTMLResponse, RedirectResponse from fastapi.responses import HTMLResponse, RedirectResponse
@@ -16,16 +19,26 @@ router = APIRouter()
@router.get("/") @router.get("/")
async def home(request: Request): async def home(request: Request):
""" """
Home page - redirect to runs if authenticated, show landing otherwise. Home page - show README and stats.
""" """
user = await get_current_user(request) user = await get_current_user(request)
if user: # Load README
return RedirectResponse(url="/runs", status_code=302) readme_html = ""
try:
readme_path = Path(__file__).parent.parent.parent / "README.md"
if readme_path.exists():
readme_html = markdown.markdown(readme_path.read_text())
except Exception:
pass
# For now, redirect to login at L2 templates = get_templates(request)
# TODO: Show a landing page with login link return render(templates, "home.html", request,
return RedirectResponse(url="/runs", status_code=302) user=user,
readme_html=readme_html,
stats={},
active_tab="home",
)
@router.get("/login") @router.get("/login")

View File

@@ -31,10 +31,16 @@
</div> </div>
{% if not user %} {% if not user %}
<div class="bg-gray-800 border border-gray-700 rounded-lg p-8 max-w-md mx-auto"> <div class="bg-gray-800 border border-gray-700 rounded-lg p-8 max-w-md mx-auto mb-12">
<p class="text-gray-400 mb-4">Sign in through your L2 server to access all features.</p> <p class="text-gray-400 mb-4">Sign in through your L2 server to access all features.</p>
<a href="/auth" class="text-blue-400 hover:text-blue-300">Sign In &rarr;</a> <a href="/auth" class="text-blue-400 hover:text-blue-300">Sign In &rarr;</a>
</div> </div>
{% endif %} {% endif %}
{% if readme_html %}
<div class="text-left bg-gray-800 border border-gray-700 rounded-lg p-8 prose prose-invert max-w-none">
{{ readme_html | safe }}
</div>
{% endif %}
</div> </div>
{% endblock %} {% endblock %}