Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 404在chrome开发工具中找不到错误CSS文件_Html_Css_Google Chrome_Google App Engine_Jinja2 - Fatal编程技术网

Html 404在chrome开发工具中找不到错误CSS文件

Html 404在chrome开发工具中找不到错误CSS文件,html,css,google-chrome,google-app-engine,jinja2,Html,Css,Google Chrome,Google App Engine,Jinja2,我花了一个半小时阅读了其他关于这个问题的帖子,但仍然没有解决它。我相信文件位于正确的位置,文件路径引用是合适的。我正在本地测试我的web应用程序,试图对其进行一点风格调整,chrome开发工具说找不到CSS文件。我正在使用Python、Google应用程序引擎和Jinja2。如果你愿意的话。提前感谢您的时间和专业知识 这是我的HTML文件。第二个继承自第一个 base.html <!DOCTYPE html> <html> <head> <titl

我花了一个半小时阅读了其他关于这个问题的帖子,但仍然没有解决它。我相信文件位于正确的位置,文件路径引用是合适的。我正在本地测试我的web应用程序,试图对其进行一点风格调整,chrome开发工具说找不到CSS文件。我正在使用Python、Google应用程序引擎和Jinja2。如果你愿意的话。提前感谢您的时间和专业知识

这是我的HTML文件。第二个继承自第一个

base.html

<!DOCTYPE html>
<html>
<head>

  <title>Chores</title>
  <link rel="stylesheet" href="static/style.css" type="text/css" />
</head>

<body>
  <a href="/" class="main-title">
    Chores
  </a>

  <div id="content">
  {% block content %}
  {% endblock %}
  </div>
</body>

</html>
这是我的应用程序。yaml

application: chorestimemadison
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"
- name: jinja2
  version: latest

我打赌你在目录访问方面遇到了问题。如果HTML文件位于templates文件夹下,并且templates文件夹是被用作的位置,那么无论您使用什么URL,HTML文件都无法访问静态文件夹(或其中的CSS文件),因为它们不是web服务器目录结构的一部分

您必须:

  • 将静态文件夹移到templates文件夹中
  • 将web服务器的根目录更改为项目名称而不是模板,并将对style.css的引用更改为
    。/static/style.css

  • 由于您的css和html文件位于并行文件夹中,您首先需要使用“./”退出1个目录,然后像这样键入css路径

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

    您键入的方式是在templates/static中查找css,因为templates是您当前的文件夹(html在其中执行)

    您缺少静态目录的处理程序:

    handlers:
    - url: /favicon\.ico
      static_files: favicon.ico
      upload: favicon\.ico
    - url: /static
      static_dir: static
    - url: .*
      script: main.app
    

    你能发布你的app.yaml处理程序吗?在我看来,静态目录可能没有正确设置。后续问题为我的答案添加一些详细信息:您使用的是Apache、nginx还是IIS?@Joshuawitley我没有使用您刚才提到的这三种技术中的任何一种。@JulianDavid您使用的是什么web服务器?您确定此网站的根目录设置为/project name吗?因为这肯定是一个访问/权限问题。@JoshuaWhitley我正在使用google app engine for python。嗯,项目文件夹在我桌面上的一个文件夹里。e、 g.desktop>some_folder>project_folder他无法升级,因为所提供的html文件位于其虚拟目录结构的根目录下。查看我的答案了解详细信息。这不是屋顶,因为屋顶是项目名称,模板和静态都是子目录。伊万,我已经尝试过了,但不幸的是,它没有起作用:(你能将“静态”文件夹移到“模板”文件夹中,只是为了看看你是否可以访问此css文件吗?还要添加“/”当你链接到像href=“./static/style.css”这样的文件时,这是一个很好的做法,我认为这可以解决它,但它没有:(然后还有一些其他问题。这对你来说还处于开发阶段,所以为什么不试着一步一步地完成[linked]教程,应该只需要几分钟,最后你就可以正确地设置好一切:)搞定了!显然,订单很重要,因为我在app.yaml中的主url后面列出了静态url,但它不起作用,但一旦我先切换到静态url,它就起作用了。非常感谢。
    <link rel="stylesheet" href="../static/style.css" type="text/css" />
    
    handlers:
    - url: /favicon\.ico
      static_files: favicon.ico
      upload: favicon\.ico
    - url: /static
      static_dir: static
    - url: .*
      script: main.app