生成具有utf-8值的链接,并将其传递到Flask路线 [英] Generate a link with utf-8 values and passing it to a Flask route
问题描述
我如何确保以下html url链接将以 utf-8
编码返回自身?
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 }}">
现在,尽管从Flask中以 utf-8
检索文件名的值,但它也没有以 utf-8
的形式构成URL链接.
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 )
我正在尝试在Apache/WSGI mod下生成与Jinja2/Flask的链接.
I'am trying to generate the link with Jinja2 / Flask under Apache/WSGI mod.
也许是mod_wsgi下的Apache导致了此问题?!
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.
根据Chrome的开发工具"/网络"标签为具有混合文件名(希腊语和英语)的测试文件生成的链接为:
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: