Demos / backend /api /routers /home_router.py
nikhile-galileo's picture
Adding finance protect demo
e68d535
raw
history blame
809 Bytes
# main.py
from fastapi import FastAPI, Request, Form
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
app = FastAPI()
# Serve static files and templates
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def read_form(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
@app.post("/search")
async def handle_search(
query: str = Form(...),
top_k: int = Form(5),
protection: bool = Form(False),
):
# Handle search logic here
result = {
"query": query,
"top_k": top_k,
"protection": protection,
}
return result