Unable to retrieve files from send_from_directory() in flask

前端 未结 5 822
忘掉有多难
忘掉有多难 2020-12-09 16:47

I have a html file which references static object like this



         


        
5条回答
  •  渐次进展
    2020-12-09 17:06

    If you look at the docs for send_from_directory you'll see that it takes the path to the directory in which the files are held on disk. Unless you have your image files saved in a root-level directory named static, you'll want to update your file path:

    send_from_directory("/some/path/to/static", "my_image_file.jpg")
    

    That being said, if you are using this for anything that will be under any load, it is better to ensure that your web server serves the files, rather than serving static files from your application.

提交回复
热议问题