Decoo's picture
Fixed codes and added Docker
36b221d
raw
history blame contribute delete
834 Bytes
from fastapi import FastAPI, Form
from fastapi.staticfiles import StaticFiles
import pandas as pd
import os
from datetime import datetime
app = FastAPI()
# Monta le cartelle esistenti
app.mount("/Data", StaticFiles(directory="Data"), name="data")
app.mount("/Images", StaticFiles(directory="Images"), name="images")
# Rotta per il feedback
@app.post("/submit-feedback")
async def feedback(user: str = Form(...), comment: str = Form(...)):
file_path = "feedback.csv"
new_entry = pd.DataFrame([[datetime.now(), user, comment]], columns=["Data", "Utente", "Commento"])
new_entry.to_csv(file_path, mode='a', header=not os.path.exists(file_path), index=False)
return {"status": "success"}
# Serve il frontend (index.html deve essere in static/)
app.mount("/", StaticFiles(directory="static", html=True), name="static")