静态样式表与谷歌应用程序引擎



我是新手,所以请耐心等待:)

我决定用jetstrap (bootstrap的视觉设计师)设计我的网站,下载html,然后用python编程后端,并将其上传到谷歌应用程序引擎。

当我从jetstrap下载文件时,我有一个包含html的文件夹和一个名为assets的文件夹,里面有3个文件夹。CSS, images, 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和images。

来自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

几乎我所做的一切,都是从网上教程。

提前感谢!

编辑:app文件夹的整个结构

google project
    app.yaml
    favicon.ico
    index.yaml
    main.py
    templates
        page1.html
        page2.html
        assets
           css
           img
           js

app.yaml中的第一个处理程序说"使目录样式表(要在应用程序根目录中找到)在URL路径/templates/assets中可用。"这可能与你想要的相反。试试这个处理程序:

- url: /assets
  static_dir: templates/assets

这将使得,例如,http://localhost:8090/assets/css/bootstrap.css返回位于templates/assets/css/bootstrap.css的文件。假设page1.html是在//page1或类似的地方提供的,那应该做你想做的。

处理程序的顺序可能导致问题:

url:/stylesheets static_dir: stylesheetsurl:/。脚本:helloworld.application

可以代替

url:/。*脚本:helloworld.applicationUrl:/stylesheets static_dir: stylesheets

我也遇到了同样的问题。我遵循了后者的所有内容,甚至是app.yaml文件中的缩进错误,如图所示。我修复了缩进,就这样了。

相关内容

最新更新