当前位置:网站首页>flask返回文件下载
flask返回文件下载
2022-07-06 07:48:00 【nongcunqq】
from flask import Flask, send_from_directory
import os
app = Flask(__name__)
@app.route("/download")
def index():
print(os.getcwd())
filename = "1.png"
path = os.path.join(os.getcwd(), filename)
return send_from_directory(path=path, directory=os.getcwd(), filename=filename,as_attachment=True)
# return send_from_directory(path='./upload/upload_cnews.xlsx', directory='./upload', filename='upload_cnews.xlsx',
# as_attachment=True)
参考
https://blog.csdn.net/qq_37754830/article/details/118884561
边栏推荐
- TS 类型体操 之 循环中的键值判断,as 关键字使用
- Sharing of source code anti disclosure scheme under burning scenario
- How to delete all the words before or after a symbol in word
- . Net 6 learning notes: what is NET Core
- Common functions for PHP to process strings
- leecode-C語言實現-15. 三數之和------思路待改進版
- Helm install Minio
- Position() function in XPath uses
- [window] when the Microsoft Store is deleted locally, how to reinstall it in three steps
- In the era of digital economy, how to ensure security?
猜你喜欢
Inspiration from the recruitment of bioinformatics analysts in the Department of laboratory medicine, Zhujiang Hospital, Southern Medical University
How to delete all the words before or after a symbol in word
Do you really think binary search is easy
[window] when the Microsoft Store is deleted locally, how to reinstall it in three steps
[redis] Introduction to NoSQL database and redis
MEX有关的学习
[count] [combined number] value series
Basics of reptile - Scratch reptile
If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]
[MySQL learning notes 32] mvcc
随机推荐
Binary tree creation & traversal
[MySQL learning notes 32] mvcc
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
烧录场景下的源代码防泄密方案分享
[非线性控制理论]9_非线性控制理论串讲
Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
Opencv learning notes 8 -- answer sheet recognition
Simulation of Michelson interferometer based on MATLAB
Inspiration from the recruitment of bioinformatics analysts in the Department of laboratory medicine, Zhujiang Hospital, Southern Medical University
数字经济时代,如何保障安全?
[CF Gym101196-I] Waif Until Dark 网络最大流
QT color is converted to string and uint
C # display the list control, select the file to obtain the file path and filter the file extension, and RichTextBox displays the data
Simulation of Teman green interferometer based on MATLAB
Get/post/put/patch/delete meaning
After the hot update of uniapp, "mismatched versions may cause application exceptions" causes and Solutions
珠海金山面试复盘
[count] [combined number] value series
Summary of Digital IC design written examination questions (I)
Is the super browser a fingerprint browser? How to choose a good super browser?