Here is the code that runs my flask server:
from flask import Flask, make_response import os app = Flask(__name__) @app.route("/") def index(): return str(os.listdir(".")) @app.route("/<file_name>") def getFile(file_name): response = make_response() response.headers["Content-Disposition"] = ""\ "attachment; filename=%s" % file_name return response if __name__ == "__main__": app.debug = True app.run("0.0.0.0", port = 6969)
If the user goes to the site, he prints the files in the directory. However, if you go to the site: 6969 / filename, it must download the file. However, I am doing something wrong, since the file size is always 0 bytes, and the downloaded file does not contain data. Any thoughts. I tried to add a content length header, and that didn't work. I donβt know what else could be.
source share