29 lines
884 B
Python
29 lines
884 B
Python
from fastapi import FastAPI, Request
|
|
from fastapi.responses import HTMLResponse
|
|
from datetime import datetime
|
|
|
|
app = FastAPI()
|
|
|
|
reportes = []
|
|
|
|
@app.get("/guia", response_class=HTMLResponse)
|
|
def guia_separacion():
|
|
with open("guia.html", "r", encoding="utf-8") as f:
|
|
return f.read()
|
|
|
|
@app.get("/reportes", response_class=HTMLResponse)
|
|
def pagina_reportes():
|
|
with open("reportes.html", "r", encoding="utf-8") as f:
|
|
return f.read()
|
|
|
|
@app.get("/alertas", response_class=HTMLResponse)
|
|
def pagina_alertas():
|
|
with open("alertas.html", "r", encoding="utf-8") as f:
|
|
return f.read()
|
|
|
|
@app.post("/api/reportes")
|
|
async def recibir_reporte(request: Request):
|
|
datos = await request.json()
|
|
datos["fecha"] = datetime.now().strftime("%d/%m/%Y %H:%M")
|
|
reportes.append(datos)
|
|
return {"mensaje": "Reporte recibido correctamente", "total": len(reportes)} |