File size: 660 Bytes
5c284c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse, FileResponse
from fastapi.staticfiles import StaticFiles
app = FastAPI()
# Monta la cartella static per servire l'HTML
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/")
async def serve_index():
return FileResponse("static/index.html")
@app.post("/chat")
async def chat(request: Request):
data = await request.json()
prompt = data.get("prompt", "")
# Simula una risposta del modello
response = f"Risposta del BOT: {prompt[::-1]}" # Esempio: risponde invertendo il messaggio
return JSONResponse({"response": response})
|