Python Forum
Serving mixed filenames with send_from_directory() errors out. - 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: Serving mixed filenames with send_from_directory() errors out. (/thread-12951.html)



Serving mixed filenames with send_from_directory() errors out. - nikos - Sep-20-2018

In an html form i have a user selecting a filename, which then i tried to send to his browser. Here is the code:

    filename = request.form.get('filename') 
    filepath = '/home/nikos/wsgi/static/files/' 

    return send_from_directory(filepath, filename) 
If the filename selected is in english characters it gets send the user, but, if it contained a mix of english + greek chars it gives a bad request i tried to encode `filename.encode("utf-8") but then NO files are being served.