【发布时间】:2013-03-03 13:44:15
【问题描述】:
我是新开发的,所以请耐心等待:)
我决定用 jetstrap(bootstrap 的可视化设计器)设计我的网站,下载 html,然后用 python 编程后端并将其上传到谷歌应用引擎。
当我从 jetstrap 下载文件时,我有一个包含我的 html 的文件夹和一个名为 assets 的文件夹,里面有 3 个文件夹。 CSS、图片、js。
如果我用浏览器打开 html,我可以看到我设计的网站。但是如果我用 python 渲染它并在 localhost 上打开它,我会看到它没有任何 css。
我尝试将文件夹添加到 app.yamal
application: web-development-test
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /templates/assets
static_dir: stylesheet
- url: .*
script: main.app
libraries:
- name: jinja2
version: latest
templates 是我的应用程序目录上的文件夹,其中包含我所有的 html 和资产,该文件夹包含 css、js 和图像。
jetstrap 的 html 的一部分是:
<link href="assets/css/bootstrap.css" rel="stylesheet">
<style>
body { padding-top: 60px; /* 60px to make the container go all the way
to the bottom of the topbar */ }
</style>
我在那里看到了 rel=stylesheet,这就是为什么我在 app.yamal 上添加 static_dir: stylesheet
我所做的几乎所有事情都来自在线教程。
提前谢谢你!
编辑: 我的应用文件夹的整个结构
google project
app.yaml
favicon.ico
index.yaml
main.py
templates
page1.html
page2.html
assets
css
img
js
【问题讨论】:
-
你能发布更多关于你的目录结构的细节吗?哪些目录位于项目的顶层,下一个等?您可能还会发现 static directory handlers 上的文档很有帮助。
-
我用我的目录结构编辑了第一篇文章。我也会看看你给我的文件。
标签: python google-app-engine assets