Reputation: 553
Is it possible on app engine (python) to point multiple static directories to a single url? In my app.yaml file I'm hoping to do something like:
ATTEMPT 1:
- url: /media/
static_dir: static/.*
ATTEMPT 2:
- url: /media/
static_dir: static/dir1
- url: /media/
static_dir: static/dir2
ATTEMPT 3:
- url: /media/
static_dir: static/dir1
static_dir: static/dir2
Using the anything notation (.*) results in both directories not working. The multiple declaration in Attempt 2 results in only the first one working (dir1) and the second one (dir2) being ignored. Attempt 3 results in a warning when I try to run the engine and allow for it to be run locally.
How can I do this without changing the url for each new static directory?
Upvotes: 1
Views: 767
Reputation: 5999
Assuming you just want everything under 'static' to serve via '/media' it should work just fine as:
- url: /media
static_dir: static
EDIT - At the time I'm writing this, this exact configuration is used here: https://imaginaryboy.appspot.com/media/dir1/text.txt
Upvotes: 1
Reputation: 6201
It is not possible. But you can make it work with links like /media-1/img.jpg, /media-2/bla.jpg, etc.
- url: /media-(.*?)/(.*)
static_files: static/dir\1/\2
upload: static/(.*?)/(.*)
More at docs.
I think that the only way out is to use simple build script, which will copy all images from /static/dir1 and /static/dir2 into media. You can use this script for one-click deployment as well. Something like this:
import os, glob
source = ['static/dir-1', 'static/dir-2']
dest = 'media'
for s in source:
for f in glob.glob(os.path.join(s, '*.*')):
shutil.copy(f, dest)
Upvotes: 2