From flask import send_from_directory@app.route ('/uploads/<filename> ') def uploaded_ File (filename): return send_from_directory (app.config[' Upload_folder '], filename) genericpath.py If the system installs this component: It will replace the system's own path function, resulting in Path has failed. The file will not be found in the end. The code has only such a short few words. This os.path.isfile is going to be a problem. So, put in the uploaded_file to complete this action, you can "" "Filename = safe_join (directory, filename) if not Os.path.isfile (filename): raise notfound () options.setdefault (' conditional ', True) Return send_file (filename, **options) The final code looks like this: #filename = flask.safe_join (Upload_folder, filename) Print (Flask.safe_join (upload_folders,secure_filename (filename)) print (os.path.isfile (filename)) Return flask.send_file (Flask.safe_join (upload_folders,secure_filename (filename)), as_attachment=true)
From the perspective of the phenomenon, It seems that genericpath.py the python itself with the path of the class rewrite, resulting in all the operation of the path to the Genericpath, this class of processing and the system comes with some of the same, so it will lead to the same method return value completely different situation,
For example: Os.path.isfile This method executes, the same file will produce different results.
An issue that occurs when you download a file by using flask that a file is not downloaded