from flask import Flask, send_file app = Flask(__name__) @app.route("/download") def download(): filename = "example.txt" return send_file(filename, as_attachment=True) if __name__ == "__main__": app.run()