fastapi实现页面文件下载功能
时间:2020-07-04 18:06:31
收藏:0
阅读:668
from starlette.responses import FileResponse @app.get("/download/{file_name}") def main(file_name: str): print(file_name) basedir = os.path.abspath(os.path.dirname(__file__)) path = basedir + ‘\\‘ + str(datetime.datetime.now().date()) file_path = path + ‘\\‘ + file_name + ‘.xlsx‘ print(file_path) return FileResponse(file_path)
原文:https://www.cnblogs.com/itBlogToYpl/p/13235716.html
评论(0)