Will Tania
Will Tania

Reputation: 25

How to write static_files exclude one subdirectory in yaml of Google App Engine

With app.yml in GAE, we use regular expressions to match a certain type of url address.

If I want to match a subdirectory of the path which is not a particula string(exclude one ), I do not know how to write regular expression?

For example:

I want to upload foo/bar/.* as static files exclude any files in foo/bar/dir/.* , how to deal with this in app.yaml .

include files in dir as static files like :

foo/bar/main.css
foo/bar/js/main.js

exclude files in dir(to use these files as application templates) like this:

foo/bar/views/index.html

The reason why I need this function is that I have mixed templates file with static files in a parent file. like Wordpress theme templates file.

Thanks.

Upvotes: 1

Views: 1201

Answers (1)

Chris Farmiloe
Chris Farmiloe

Reputation: 14185

Most people keep all their static files in a subdirectory called "public" or "static" to avoid this issue, and I recommend you do the same.

You could add a line to catch your files by extension like:

- url: /foo/bar/([^.]+\.(js|css))
  static_files: foo/bar/\1
  upload: foo/bar/[^.]+\.(js|css)

Upvotes: 4

Related Questions