Nate
Nate

Reputation: 2047

Configuring Python GAE app.yaml for Static Files

I am trying to get all URL references to a .css file to point to a single css directory inside of a GAE Python 2.7 project. For example, I want all of these URLs...

http://website.com/style.css
http://website.com/a/style.css
http://website.com/a/b/c-d-e/style.css

... to point to this file in GAE...

/css/style.css

Here is the app.yaml entry that I have been playing with:

- url: /.*([^/]*\.css)
  static_files: css/\1
  upload: css/.*

What I think I am doing is...
url: Use any URL with a .css at the end. Group a string at the end which does not contain a forward slash and which ends in ".css".
static_files: Use the group to reference the file within the css folder.
upload: Select all files in the css folder as eligible files.

What am I doing wrong? Points if you can explain your reply. Bonus points if you can explain what the upload item is really for. Thanks!

Upvotes: 2

Views: 507

Answers (1)

Gricha
Gricha

Reputation: 1032

This worked for me:

- url: /.*?([^/]*\.css)
  static_files: css/\1
  upload: css/.*\.css

First thing is in url regex. After /.* you should put '?' because you want your regex to be lazy not greedy. Otherwise it'll just suck whole url to the .css part because, well, why not.

Second thing is - in upload part I added .css at the end. It was wild guess by me and I didn't worked out why it helped yet.. :)

Hopefully this helps. Is that what you wanted?

Upvotes: 1

Related Questions