Python Forum
Cannot serve file with send_from_directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot serve file with send_from_directory
#1
# Prepare selected file for download...
filepath = '/home/nikos/wsgi/static/files/'
send_from_directory( filepath, filename, as_attachment=True )
'filename' is a valid filename value
i get the following error:

Quote:Bad Request
The browser (or proxy) sent a request that this server could not understand.

Why instead of serving the file the error mentions proxy or bad request?
The script is a mod_wsgi script.
Reply
#2
I came to realize that it was due to the filenames containing a mix of latin+greek cjaracters that gave this "Bad Request Error". I turned the filename only to Greek letters and now it doesn't produce this error, but also it does NOT send the file to the the users browser. Any idea why?
Reply
#3
Actually i found it myself, i had to put it like this in order for pyhton to be able to send the file send_from_directory( filepath, filename) Problem now is that if my filanme has greek letters iwhtin i still get bad request. Why is that?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Flask, send_from_directory not working : solved SpongeB0B 2 7,346 Jan-26-2021, 07:02 AM
Last Post: SpongeB0B
  Serving mixed filenames with send_from_directory() errors out. nikos 0 1,857 Sep-20-2018, 03:11 AM
Last Post: nikos
  Django serve list-file foralobo 4 4,318 Oct-03-2017, 03:48 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020