Using Flask, I can render different templates based on the url. For example :
- http://example.com/site1/ ; will render templates/site1/{htmls}
- http://example.com/site2/ ; will render templates/site2/{htmls}
This works really great with jinja_loader and a custom Loader, but now I'm stuck with the static files.
The static files depends on the template, so they are located in templates/static/site{0-9}, but of course, I cannot set a jinja_loader on the static_folder parameter because it's not related to Jinja but to Flask.
How can I render the correct static folder based on the current URL?
As an example, here's the loaded code:
Flask(app_name,
static_url_path = '/public',
static_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates/static')
)
and in templates/static, I have :
static/
site1/
css/
js/
images/
site2/
css/
js/
images/
etc...
url_for('static', 'site1/css/...'), etc. to generate the correct URLs already? What is the exact problem here?{{url_for('static', filename='css/...')}}. Ideally, I would modify where Flask search for the static files when rendering/public/css/..., to search not in/templates/static/css/..., but in/templates/static/site1/css/...staticview handler then.