Python Forum
Cannot serve file with send_from_directory - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Cannot serve file with send_from_directory (/thread-12869.html)



Cannot serve file with send_from_directory - nikos - Sep-17-2018

# 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.


RE: Cannot serve file with send_from_directory - nikos - Sep-18-2018

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?


RE: Cannot serve file with send_from_directory - nikos - Sep-19-2018

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?