Spaces:
No application file
No application file
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
from fastapi import FastAPI, Request
|
| 2 |
-
from fastapi.responses import FileResponse
|
| 3 |
-
from docxtpl import DocxTemplate
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
import uuid
|
| 6 |
-
|
| 7 |
-
app = FastAPI()
|
| 8 |
-
|
| 9 |
-
@app.post("/generate-pop")
|
| 10 |
-
async def generate_pop(request: Request):
|
| 11 |
-
data = await request.json()
|
| 12 |
-
|
| 13 |
-
doc = DocxTemplate("Modelo_POP_v1.docx")
|
| 14 |
-
doc.render(data)
|
| 15 |
-
|
| 16 |
-
filename = f"POP_{uuid.uuid4().hex[:8]}.docx"
|
| 17 |
-
filepath = Path(filename)
|
| 18 |
-
doc.save(filepath)
|
| 19 |
-
|
| 20 |
-
return FileResponse(
|
| 21 |
-
path=filepath,
|
| 22 |
-
media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 23 |
-
filename=filename
|
| 24 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|