首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >文件夹中的html图像未显示

文件夹中的html图像未显示
EN

Stack Overflow用户
提问于 2022-10-10 18:20:45
回答 2查看 26关注 0票数 -1

结构:

代码语言:javascript
复制
root_project
   -templates
      -pictures
         img.png
      -home.html

   -flask_session.py

我正在flask_session.py中运行一个Flask应用程序,我想在多个柔性盒容器中显示图像,如果我使用到图像的链接,一切都可以正常工作,但是当我使用文件路径时,它就不能工作了。

代码语言:javascript
复制
            <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 -

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-10-10 22:27:16

尝试构建这样的目录:

代码语言:javascript
复制
app/static/img/your_img.jpg

希望能帮上忙。

票数 1
EN

Stack Overflow用户

发布于 2022-10-10 18:27:50

图片在图片目录中,您正在尝试在没有根目录的情况下访问它们。1)完整的文件目录可以运行2)导入os cwd = os.getcwd() full_path =C:\Windows\image.png

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74019206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档