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
任何建議?