gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:56:06 24 4
gpt4 key购买 nike

我已经使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com