【发布时间】:2015-05-03 10:34:24
【问题描述】:
我已经花了一个半小时阅读有关此问题的其他帖子,但仍未解决。我相信该文件位于正确的位置,并且文件路径引用是适当的。我正在本地测试我的 Web 应用程序,试图对其进行一些样式化,而 chrome 开发工具说找不到 CSS 文件。我正在使用 Python、Google App Engine 和 Jinja2。 Check out the error 如果您愿意,可以自己使用。提前感谢您的时间和专业知识!
这是我的 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>
front.html
{% extends "base.html" %}
{% block content %}
<br>
<br>
<a href="/dochore">Do Chore</a>
<a href="/addchore"> + Add Chore</a>
<a href="/removechore"> - Remove Chore</a>
<a href="/choredetail">Chore Details</a>
<br>
<br>
<br>
{% for chore in chores %}
{{ chore.render() | safe }}
<br><br>
{% endfor %}
{% endblock %}
我的项目目录的结构类似于...
project-name/
main.py
templates/
HTML files
static/
style.css
这是我的 app.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
【问题讨论】:
-
您可以发布您的 app.yaml 处理程序吗?在我看来,静态目录可能没有正确设置。
-
后续问题为我的回答添加一些细节:您使用的是 Apache、nginx 还是 IIS?
-
@JoshuaWhitley 我没有使用你刚才提到的这三种技术中的任何一种。
-
@JulianDavid 您使用的是什么网络服务器?您是否肯定将此网站的根目录设置为 /project-name?因为这绝对是一个访问/权限问题。
-
@JoshuaWhitley 我正在为 python 使用谷歌应用引擎。嗯,项目文件夹位于我桌面上的一个文件夹中。例如桌面 > some_folder > project_folder
标签: html css google-chrome google-app-engine jinja2