Content-Disposition
-
flask 파일 다운로드하기 (send_file, Content-Disposition)TIL 2022. 10. 29. 08:23
#1 서론 프로젝트를 진행하면서 사용자가 어떤 파일을 다운로드 받게 하는 기능을 구현했다. 위의 내용을 정리하여 글을 쓴다. #2 본론 #2-1 저장되어있는 파일을 다운로드 파일을 다운로드 시키려면 아래의 코드를 쓰면 된다. send_file([file_route], mimetype=[mimetype], as_attachment=True) [] 안에 들어가는 것들을 알아서 넣고, 예시와 비슷한 코드를 만들어서 실행하면 된다. #예시 from flask import send_file @app.route("/download") def download_test(): retrun send_file("download_files/test.text", mimetype="text/plain", as_attachment..