- Set static url (for staging and production) to (bunny.net) static storage
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from flask import Flask, jsonify, request
|
||||
from flask import Flask, jsonify, request, url_for
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
import logging.config
|
||||
|
||||
@@ -63,6 +63,18 @@ def create_app(config_file=None):
|
||||
# Register Cache Handlers
|
||||
register_cache_handlers(app)
|
||||
|
||||
# Custom url_for function for templates
|
||||
@app.context_processor
|
||||
def override_url_for():
|
||||
return dict(url_for=_url_for)
|
||||
|
||||
def _url_for(endpoint, **values):
|
||||
static_url = app.config.get('STATIC_URL')
|
||||
if endpoint == 'static' and static_url:
|
||||
filename = values.get('filename', '')
|
||||
return f"{static_url}/{filename}"
|
||||
return url_for(endpoint, **values)
|
||||
|
||||
# Debugging settings
|
||||
if app.config['DEBUG'] is True:
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user