Spaces:
Runtime error
Runtime error
| import logging | |
| from fastapi import APIRouter | |
| from fastapi.responses import FileResponse | |
| from components.services.files import FileService | |
| router = APIRouter() | |
| logger = logging.getLogger(__name__) | |
| service = FileService() | |
| async def download_file(filename: str): | |
| file_path = service.prepare_file(filename) | |
| return FileResponse( | |
| file_path, | |
| filename=filename, | |
| media_type="application/xml", | |
| headers={ | |
| "Content-Type": "application/xml; charset=cp866", | |
| "Access-Control-Expose-Headers": "Content-Disposition" | |
| } | |
| ) | |
| async def download_pdf(filename: str): | |
| file_path = service.prepare_pdf(filename) | |
| return FileResponse( | |
| file_path, | |
| filename=f'{filename}.pdf', | |
| media_type="application/pdf", | |
| headers={ | |
| "Content-Type": "application/pdf", | |
| "Access-Control-Expose-Headers": "Content-Disposition" | |
| } | |
| ) | |