Question

How to specify a path to serve some files from one of two directories similar to

- url: /scripts
  static_dir: ../(app|.tmp)/scripts

I want any calls to /scripts to be serve from either

../app/scripts
../.tmp/scripts

tried different options like

static_dir: ../app|.tmp/scripts
static_dir: ../(.*?)/scripts

but didn't work.

reference https://developers.google.com/appengine/docs/python/config/appconfig

Was it helpful?

Solution

There are two mistakes:

  1. You cannot point to files that are on lower level than your app.yaml, because whatever is outside is not handled by Google App Engine, so never start with ../ in your app.yaml files.

  2. As you can see from the docs regarding the static_dir is a directory that will be uploaded with the application as static files, so trying to upload two directories that pointing to the same path doesn't make much sense and most likely will fail even if the regexp going to succeed.

So the answer to your question is: this not really possible. I would suggest to put all your files that you want to serve into one folder that is on the same level (or deeper) with the app.yaml and point it there.

OTHER TIPS

-The vertical bar | in your first regex applies its "or" function to the entirety of what's on its left and right, so it's actually looking for "../app" OR ".tmp/scripts".

-The dot is a special character in regex that matches anything other than newline characters. It's not causing these patterns to fail since it will match the literal ".", but it is making your regex more accepting that you probably want it to be.

-Your second pattern should actually work, but if you're only ever going to have "app" or ".tmp" in that location, you should probably go with those specifically.

Thus your regex should look like this: \.\./(?:app|\.tmp)/scripts

As for why your second regex didn't succeed in matching, it could be due to your code treating the forward slash as a delimiter, in which case you'll need to escape each one with a backslash: \.\.\/(?:app|\.tmp)\/scripts

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top