javascript - 如何将 Bootstrap 、css、图像、js 添加到谷歌应用引擎?

标签 javascript css twitter-bootstrap google-app-engine python-2.7

我已经使用 bootstrap 创建了网络应用程序。我将它上传到谷歌应用引擎。我的问题是,它没有显示我添加的任何图像、js 或 css。请帮助我。我的文件夹结构如下。

-myapp
  -css
  -js
  -images
  -fonts
  -index.html
  -otherfiles.html....

我按如下方式编辑了 app.yaml

application: website-example
version: 1
runtime: python
api_version: 1

default_expiration: "7d"

handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css|swf|xml))
  static_files: \1
  upload: (.*\.(gif|png|jpg|ico|js|css|swf|xml))

- url: /(.*\.html)
  static_files: \1
  upload: index.html

- url: /.*
  script: main.p

我如下编辑了 main.py。

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class IndexHandler(webapp.RequestHandler):
    def get(self):
        if self.request.url.endswith('/'):
            path = '%sindex.html'%self.request.url

        self.redirect(path)

    def post(self):
        self.get()

application = webapp.WSGIApplication([('/.*', IndexHandler)], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

请帮帮我。我想不通。

最佳答案

对于你的情况,我会使用更像的东西:

application: website-example
version: 1
runtime: python
api_version: 1

default_expiration: "7d"

handlers:
- url: /css
  static_dir: css

- url: /js
  static_dir: js

- url: /img
  static_dir: images

- /index.html
  static_files: index.html
  upload: index\.html

- url: /.*
  script: main.py

css、js 和图像的静态目录背后的基本思想是,只要请求 url 以这些 url 开头,这些目录下的所有内容都将静态提供(因此,您可以提供类似/img/sub_dir/foo. png)

对于静态 html,我使用了单个文件示例,但您也可以将它们放在单独的目录中并从那里静态提供

关于javascript - 如何将 Bootstrap 、css、图像、js 添加到谷歌应用引擎?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27119608/

相关文章:

php - 调用在另一个 <div> 中返回一个 <div> 的 php 自定义函数

javascript - 勾选复选框后更改颜色表

html - 如何使 Twitter Bootstrap 工具提示看起来像弹出窗口(没有标题行)?

javascript - setAttribute ("value")不适用于密码字段

javascript - 将一个 RxJS observable 的结果传递到下一个连续的 observable

jquery - DIV 中的淡入和淡出文本 - 删除循环

html - 如何包含 Font Awesome 图标以及如何在 html 中绑定(bind)

html - Bootstrap 网格列重新排序

javascript - html javascript 折叠 Accordion

javascript - D3.js:代码不起作用