Questions tagged [fileresponse]
9 questions
3
votes
1 answer
How to load a different file than index.html in FastAPI root path?
Here is a simple static FastAPI app. With this setup even though the root path is expected to return a FileResponse of custom.html, the app still returns index.html. How can I get the root path work and render custom.html?
from fastapi import…

Abbas
- 3,872
- 6
- 36
- 63
2
votes
0 answers
Returning a file in FastAPI without saving it locally
In FastAPI I know that I can return a file (in FileResponse) by passing its path and filename as parameters. Is there any way I can return the file directly without having to save it locally and use the path?
Here's a part of the code for…

Sara Karam
- 21
- 3
1
vote
1 answer
Django: Problems with Fileresponse in production
Django: Fileresponse works fine in local but it doesnt in deployment
In local i did this
@login_required
@permission_required('plataforma.ADMIN', raise_exception=True)
def admin_descargar_planilla(request,plantilla_id):
try:
plantilla =…

Snorlax Russo
- 11
- 1
1
vote
2 answers
How to return both a PDF file and a Jinja2 Template Response using FastAPI?
My FastAPI application returns a PDF file when a certain button is clicked. Is there a way to return both a FileResponse (starlette.responses) and a Jinja2 TemplateResponse at the same time?
def generate_report(request: Request, start_date: date =…

Ukhu
- 19
- 3
0
votes
2 answers
How to generate and return a PDF file from in-memory buffer using FastAPI?
I generate a PDF file using PyFPDF library and would like to return this in-memory buffer without writing it to local disk.
@app.post("/pdf")
def generate_report(id_worker: int = Form(...), start_date: date = Form(...), end_date: date =…

Ukhu
- 19
- 3
0
votes
1 answer
How to send a file response to a user in Django application after some processing
I'm working on a solution which translates CSV/TSV files from one language to the other. I've built a Django application that accepts the file and the target/source language(s) using a form.
Once the user provides the data, the file is processed…

usama hussain
- 57
- 6
0
votes
0 answers
The view web_vulnerability_scan.views.pdf didn't return an HttpResponse object. It returned None instead
Yesterday,when I try this function,it still working fine but today it suddenly shows this error,what is the problem?I could not post the complete coding,but I searched online,they said should be the if part problem,I have no idea how to fix…

Help
- 11
- 3
0
votes
1 answer
Django call function to save file cannot work
I am create Django project and create function for download file, But my project cannot work, File not response to save
view.py
from django.http.response import HttpResponse
from django.conf import settings
from django.http import HttpResponse,…

MaTaDoRcpe
- 79
- 1
- 1
- 8
0
votes
1 answer
FastAPI FileResponse not entering the except block
Good afternoon friends.
I am having issues with FastApi's FileResponse and catching FileNotFoundError (or any, really) exceptions.
Here's my script:
import os
import sys
from fastapi import FastAPI, HTTPException, File, UploadFile
from…

Rafael Antonio Pólit
- 175
- 1
- 10