Download app.py from AleRive/chat: direct link, hf CLI and curl.
- Browser
- Download file 660 Bytes
-
https://huggingface.co/spaces/AleRive/chat/resolve/main/app.py
- Command line
-
hf download hf://spaces/AleRive/chat/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AleRive/chat/resolve/main/app.py
660 Bytes
| 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") | |
| async def serve_index(): | |
| return FileResponse("static/index.html") | |
| 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}) | |