Spaces:
Runtime error
Runtime error
File size: 1,000 Bytes
e68d535 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import uvicorn
from fastapi import FastAPI, Form
from fastapi.responses import JSONResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from fastapi.requests import Request
from fastapi.responses import HTMLResponse
from dotenv import load_dotenv
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def read_root(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
@app.post("/search")
async def search(
query: str = Form(...),
top_k: int = Form(5),
protection: bool = Form(False)
):
# Simulate processing
return JSONResponse({
"message": "Search response here!",
"query": query,
"top_k": top_k,
"protection": protection
})
if __name__ == "__main__":
load_dotenv()
uvicorn.run(app, host="0.0.0.0", port=8000)
|