简体   繁体   English

如何在app.yaml中定义嵌套的静态目录?

[英]How to define nested static directories in app.yaml?

I have static directory "/static", with js and css files, and inside it another directory "images". 我有带有js和css文件的静态目录“ / static”,并且在其中有另一个目录“ images”。 How can I define this in app.yaml so that images are accessible from js and css files using relative directories? 如何在app.yaml中定义它,以便可以使用相对目录从js和CSS文件访问图像? For example, in "/static/main.css": 例如,在“ /static/main.css”中:

.bck {background-image: url(images/img.png); }

Should refer to "/static/images/img.png". 应该参考“ /static/images/img.png”。

The following doesn't work: 以下内容不起作用:

handlers:

- url: /static
  static_dir: static

- url: /static/images
  static_dir: static/images

In your app.yaml you need to define once a static directory like this. 在您的app.yaml中,您需要像这样定义一次静态目录。

- url: /static
  static_dir: static
  expiration: "7d"

In your static directory you can create other directory for js or css or images and It's not necessary to redeclare theme. 在您的静态目录中,您可以为js或CSS或图像创建其他目录,而无需重新声明主题。

To call you static files you need just to specify your static path like this: /static/images/xxxx.png 要调用静态文件,您只需要指定静态路径,如下所示:/static/images/xxxx.png

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

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