- Set static url (for staging and production) to (bunny.net) static storage

This commit is contained in:
Josako
2025-09-05 07:55:57 +02:00
parent 54a9641440
commit 6115cc7e13
4 changed files with 135 additions and 43 deletions

View File

@@ -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)