【问题标题】:CSS file not found error 404 when I try to run flask code当我尝试运行烧瓶代码时,未找到 CSS 文件错误 404
【发布时间】:2020-07-09 07:12:35
【问题描述】:

我在编程实践 Web 开发方面相当陌生。我的 css 文件有一个问题,当我将它链接到我的 html 并运行 python 代码时,它会产生一个错误,即找不到 css 文件。这是 git 存储库的链接。提前致谢。 https://github.com/NelsonNNN/SecondApp.git

【问题讨论】:

    标签: python css http-status-code-404


    【解决方案1】:
    1. 在根目录中,创建一个名为static 的文件夹。
    2. css 文件夹移动到static
    3. layout.html

    替换

    <link rel="stylesheet" type="text/css" href="../css/style.css">
    

    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css')}}">
    

    【讨论】:

    • 非常感谢这个工作。但我很好奇为什么它不会直接接收 css 文件……或者这是要使用的新格式?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 2015-01-22
    • 2020-01-13
    • 2021-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多