Flask send_from_director throws an exception
Recently, during the product development of a factory, the send_from_directory API in Flask was called. The calling method is as follows:
Send_from_directory (dirpath, filename, as_attachment = false)
When it runs, the result does not live up to expectations, and an exception is thrown at this point of execution.
Resolution process:
Verify that the parameters of dirpath and filename are correct and the contents of the file are normal.
Write an offline test case, call the same parameters, execute the test case, and the return value is as expected. . What to do:.; is the output using the problem? update the clean output; the return value of the new output interface is as expected; the difference between the new output and the old output is that the output contains the pyc file during debugging; clean up the pyc file in the old output, re-execute it, and the interface call is normal.
Summary:
Make sure the site is clean before debugging.