File size: 834 Bytes
36b221d
 
 
42c7519
fa98eea
2734a24
36b221d
2734a24
36b221d
 
 
42c7519
36b221d
 
 
 
 
 
 
2863108
36b221d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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")