结构:
root_project
-templates
-pictures
img.png
-home.html
-flask_session.py我正在flask_session.py中运行一个Flask应用程序,我想在多个柔性盒容器中显示图像,如果我使用到图像的链接,一切都可以正常工作,但是当我使用文件路径时,它就不能工作了。
<div class="crate crate-1">
<img src="pictures/img.png" />
</div>
<div class="crate crate-2">
<img src="/pictures/img.png" />
</div>
<div class="crate crate-3">
<img src="./pictures/img.png" />
</div>
<div class="crate crate-4">
<img src="img.png" /> <!-- I even tried putting the image into the same folder as my html files and also in the root file, it still didn't work -->
</div>不管我做什么,我都会得到404。
"GET /pictures/img.png HTTP/1.1" 404 -
发布于 2022-10-10 22:27:16
尝试构建这样的目录:
app/static/img/your_img.jpg希望能帮上忙。
发布于 2022-10-10 18:27:50
图片在图片目录中,您正在尝试在没有根目录的情况下访问它们。1)完整的文件目录可以运行2)导入os cwd = os.getcwd() full_path =C:\Windows\image.png
https://stackoverflow.com/questions/74019206
复制相似问题