My app contains a large folder structure of images. In production, the images are served from a CDN. In dev, we have a small sampling of the images available on a dev server.
I'm familiar with using url_for
to serve files from the /static folder:
<img src="{{ url_for('static', filename='images/logo.png') }}"/>
I want to only use the /static folder for application-ish things (like js, css and images such as the logo and button icons -- things that go with the templates)
The application's main data is a huge repo of images. That's on the CDN, not in with the source code.
I'd like to do this:
<img src="{{ url_for('image_repo', filename=viewmodel.imagename) }}"/>
And have that translate to this:
Development:
http://devbox/folder/images/blahblah.png
Production:
http://cdn.domain.com/bucket/blahblah.png
The Flask documentation talks about creating an endpoint function. I'm not doing it right because it's throwing an error. The error is not on this endpoint function, but on the url_for. It says "werkzeug.routing.BuildError" and shows me: BuildError: ('image_repo', {'filename': u'blahblah.png'}, None)
Here is my endpoint function. I know it's wrong.
@app.endpoint('image_repo')
def image_repo(filename):
# use settings to figure out if this is dev or prod
# then what ????
pass