我有一个flask应用程序,正在尝试设置下载位置,其中下载的文件以“。”开头。 (点或句点)。下面列出了代码,但是我尝试了几种方法,每种方法都只是在开始时删除了“点”。我觉得这应该很简单,但是我陷于困境。任何帮助,将不胜感激。
谢谢
@app.route('/.blah.auth', methods=['GET'])
def downloadBlahAuth(roleLevel = app.config["PAGE_ROLE_LEVELS"][".blah.auth"]):
"""
filePath = os.path.join(app.config["DOWNLOADS_FOLDER"], ".blah.auth");
theFile = open(filePath, "r")
fileText = theFile.read()
theFile.close()
strIO = StringIO.StringIO()
strIO.write(fileText)
strIO.seek(0)
return send_file(strIO, attachment_filename=".blah.auth", as_attachment=True)
"""
fileName = ".blah.auth"
return send_from_directory(directory=app.config["DOWNLOADS_FOLDER"], filename=fileName)