How can i ensure that the following html url link is going to return itself with utf-8
encoding?
<meta http-equiv="REFRESH" content="5; URL=http://superhost.gr/files/download?filename={{ filename }}">
As it is now, although the value of filename is being retrieved from Flask as utf-8
it doesn't form the URL link also as utf-8
.
Here is how i'm fetching this value and try to use it to download a file.
# Prepare selected file for download...
if request.args:
filename = request.args.get('filename') # value comes from template url link
filepath = '/static/files/'
return send_from_directory( filepath, filename, as_attachment=True )
I'am trying to generate the link with Jinja2 / Flask under Apache/WSGI mod.
Perhaps Apache under mod_wsgi is causing this issue?!
The error i'am seeing in the browser is:
Bad Request
The browser (or proxy) sent a request that this server could not understand.
The link that is generated according to Chrome's Developer Tool/Network Tab for a a test file with a mixed filename(greek + english) is:
{{ filename }}
? – ShirtmakerΝικόλαος
το the parameter. In my case the value is being retrived from Bottle framework with the correct encoding but unfortunately when<meta http-equiv="REFRESH" content="5; URL=http://superhost.gr/files/download?file={{ filename }}">
forms it doesnt redirect to the url with utf-8 encoding. Hoe cna i ensure that? – Yoofilename
in it or watring for set value in{{ filename }}
then running code – Shirtmaker?file={{ filename }}
to the link as utf-8 – Yoosend_from_directory( filepath, filename, as_attachment=True )
cannot download the file because its filename contains non latin-characters, which means that the url is notutf-8
formatted. – Yoofilename
query variable and then use that link to load a flask route the filename returned from the link its NOT formed in`utf8' therefore iam getting an error. I'm displaying my code in my question, what else do you want me to show you? – Yoo