html - CSS 文件未加载 GAE

标签 html css google-app-engine

我将一个 CSS 文件作为静态文件添加到我的元素中只是为了尝试它是如何工作的,但我从一开始就失败了。

CSS 文件是:

body {
    background:#00FF00;
}

我配置的 app.yaml 文件是;

application: s~my_app_id
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /stylesheets
  static_dir: stylesheets

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

- url: /.*
  script: main.app

- url: /remote_api
  script: google.appengine.ext.remote_api.handler.application
  login: admin

libraries:
- name: webapp2
  version: 2.5.1

- name: jinja2
  version: latest

builtins:
- remote_api: on

在本地或者我部署后都不行,而我在main.py中的页面内容是;

<!DOCTYPE html>
    <html>
       <head>
          <link type="text/css" rel="stylesheet" href="stylesheets/main.css"/>
       </head>
       <body>
          some stuff
       </body>
   </html>

以及我的页面内容在浏览器中的情况;

<html>
    <head>
       <style type="text/css"></style>
    </head>
    <body>
        some stuff
    </body>
</html>

我没有收到任何错误或日志,一切看起来都很完美。我尝试在 chrome 和 ie10 中显示这个

最佳答案

我认为你应该尝试在你的 app.yaml 中声明它:

application: my-gae-app
version: 2013
runtime: python27
api_version: 1
threadsafe: true

default_expiration: "14d 5h"

handlers:
- url: /css
  static_dir: css

如果像上面那样声明,CSS 将会加载。您还必须在 HTML 中正确加载它:

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

documentation .

关于html - CSS 文件未加载 GAE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18722648/

相关文章:

java - Google AppEngine 500 错误

android - 客户端与 Cloud Endpoints 的客户端通信

javascript - 如何避免这种情况? Yslow -> "This page has 5 external stylesheets. Try combining them into one."

html - Flexbox 不适用于页面响应

html - 内联 block 元素换行时的CSS,父包装器不适合新宽度

html - 如何为网站制作程序?我应该知道什么类型的技能/代码?

javascript - php中获取dropdownlist的值

javascript - 使网站元素与(小)网格对齐

html - 将 2 张图片相互放置的响应方式,如 Facebook 和 google plus

google-app-engine - jTwitter、oAuth 和 Google App Engine。没有发现类定义错误