1
为了好玩,我正在制作上传/下载服务,但我一直在努力为静态目录之外的文件提供服务,因为任何人都可以访问www.mysite.com /静态并查看内容。从静态目录以外的瓶子提供瓶子文件
这是我到目前为止。请原谅我的网络存储:)
if not os.path.exists('\\ATTILA\\Development\\GIT\\MyCloud\\static\\'+ session['username']):
os.makedirs('\\\\ATTILA\\Development\\GIT\\MyCloud\\static\\'+ session['username'])
#Download links for all files
pathing = []
my_path = '\\\\ATTILA\\Development\\GIT\\MyCloud\\static\\'+ session['username'] + '\\'
os.chdir('\\\\ATTILA\\Development\\GIT\\MyCloud\\static\\'+ session['username'])
for myfile in glob.glob('*'):
downs = my_path + myfile
pathing.append(tuple([downs, myfile]))
在我的模板丑陋的路径,我有一个简单的for循环
{% for myfile, name in pathing %}
<a href='{{ myfile }}' download>{{ name }}</a><br>
{% endfor %}
所以我的看法是这样的:
由于它代表我的文件是可下载的,但是如果我将下载的文件路径更改为“静态”之外的文件夹,那么不用下载链接,我会得到404错误,即po诠释到URL +文件路径像这样www.mysite.com\ATTILLA\Development\some_other_folder
任何建议?