Add root html endpoint

This commit is contained in:
Marty Oehme 2025-06-05 19:11:53 +02:00
parent fed9f0a3d8
commit 450ec9d692
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -9,6 +9,7 @@ from uuid import uuid4
import feedparser
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse
from groq import Groq
BEE_FEED = "https://babylonbee.com/feed"
@ -185,6 +186,24 @@ def improve_summary(original_title: str, new_title: str, original_summary: str):
return rewrite_summary_with_groq(o, new_title)
@app.get("/", response_class=HTMLResponse)
def root_route():
return """
<!DOCTYPE html>
<html>
<head>
<title>FastAPI with HTMX</title>
<script src="https://unpkg.com/htmx.org@1.6.1"></script>
</head>
<body>
<h1>Welcome to FastAPI with HTMX</h1>
<div id="content"></div>
<button hx-get="/fetch-data" hx-target="#content">Fetch Data</button>
</body>
</html>
"""
def start() -> None:
from uvicorn import run