简体   繁体   English

Google App Engine中的CSS映射问题

[英]CSS mapping issue in Google App Engine

I'm writing a python webapp application for Google App Engine and I'm having some issues with the URL mapping. 我正在为Google App Engine编写一个python webapp应用程序,但URL映射存在一些问题。 For some reason, we wanted to put the index.html file inside another folder (not in the same folder with the main.py file). 由于某些原因,我们希望将index.html文件放在另一个文件夹中(而不是与main.py文件位于同一文件夹中)。 Everything worked fine except that we can't access our CSS file. 一切工作正常,除了无法访问CSS文件。 This is my app.yaml file: 这是我的app.yaml文件:

application: testApp
version: 1
runtime: python27
api_version: 1
threadsafe: false

handlers: 

- url: /css
  static_dir: test/gui/css

- url: /(.*\.(gif|png|jpg|ico))
  static_files: test/\1
  upload: test/(.*\.(gif|png|jpg|ico))

- url: /game/.*
  script: game.app

- url: /.*
  script: main.app

libraries:
- name: jinja2
  version: latest

This is my URL mapping in main.py: 这是我在main.py中的URL映射:

app = webapp2.WSGIApplication([('/', MainHandler)
                            ], debug=True, config=config)

This is how my files are structured: 这是我的文件的结构:
main.py main.py
/test/index.html /test/index.html
/test/gui/css/stylesheets.css <-- the file that I wanted to access /test/gui/css/stylesheets.css <-我要访问的文件
/test/gui/images <-- the images in this folder can be accessed without any problems / test / gui / images <-可以毫无问题地访问此文件夹中的图像

I've tried googling and browsing through the posts in Stackoverflow, but I couldn't find any working solutions yet. 我曾尝试使用Google搜索和浏览Stackoverflow中的帖子,但是找不到任何可行的解决方案。 Your help will be much appreciated, thanks! 非常感谢您的帮助,谢谢!

What is your statement that accesses the css files in your HTML code? 您访问HTML代码中的CSS文件的语句是什么? It should look something like this: 它看起来应该像这样:

<link rel="stylesheet" href="/css/css_file_1.css">

try to append a slash: 尝试添加一个斜杠:

- url: /css/
  static_dir: test/gui/css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM