Python Forum
Serving mixed filenames with send_from_directory() errors out.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Serving mixed filenames with send_from_directory() errors out.
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Flask, send_from_directory not working : solved SpongeB0B 2 7,345 Jan-26-2021, 07:02 AM
Last Post: SpongeB0B
  Django serving wrong template at the wrong address with malformed urls.py (redactor a Drone4four 2 2,528 Aug-17-2020, 01:09 PM
Last Post: Drone4four
  malformed header from script 'main.py': Bad header: * Serving Flask app "main" anuragsapanbharat 2 4,460 Jun-12-2019, 07:26 AM
Last Post: anuragsapanbharat
  [Flask] flask not submitting text entry when mixed with checkbox entries Prince_Bhatia 4 8,450 Oct-12-2018, 05:40 PM
Last Post: snippsat
  Cannot serve file with send_from_directory nikos 2 2,477 Sep-19-2018, 09:25 PM
Last Post: nikos

Forum Jump:

User Panel Messages

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