Simplify the handling of /static

master
Florent Daigniere 3 years ago
parent aee089f3b1
commit d3f07a0882

@ -11,7 +11,7 @@ import hmac
def create_app_from_config(config): def create_app_from_config(config):
""" Create a new application based on the given configuration """ Create a new application based on the given configuration
""" """
app = flask.Flask(__name__) app = flask.Flask(__name__, static_folder='static_files', static_url_path='')
app.cli.add_command(manage.mailu) app.cli.add_command(manage.mailu)
# Bootstrap is used for error display and flash messages # Bootstrap is used for error display and flash messages
@ -62,7 +62,6 @@ def create_app_from_config(config):
app.register_blueprint(ui.ui, url_prefix='/ui') app.register_blueprint(ui.ui, url_prefix='/ui')
app.register_blueprint(internal.internal, url_prefix='/internal') app.register_blueprint(internal.internal, url_prefix='/internal')
app.register_blueprint(sso.sso, url_prefix='/sso') app.register_blueprint(sso.sso, url_prefix='/sso')
app.register_blueprint(static_files.static, url_prefix='/static')
return app return app

@ -1,5 +1,5 @@
from flask import Blueprint from flask import Blueprint
sso = Blueprint('sso', __name__, static_folder='static', template_folder='templates') sso = Blueprint('sso', __name__, template_folder='templates')
from mailu.sso.views import * from mailu.sso.views import *

@ -1,5 +0,0 @@
from flask import Blueprint
static = Blueprint('static', __name__, static_folder='static', static_url_path='/static')

@ -129,16 +129,10 @@ http {
# Actual logic # Actual logic
{% if ADMIN == 'true' or WEBMAIL != 'none' %} {% if ADMIN == 'true' or WEBMAIL != 'none' %}
location ^~ /sso { location ~ ^/(sso|static) {
include /etc/nginx/proxy.conf; include /etc/nginx/proxy.conf;
proxy_pass http://$admin; proxy_pass http://$admin;
} }
location ^~ /static {
include /etc/nginx/proxy.conf;
rewrite ^/static/(.*) /static/static/$1 break;
proxy_pass http://$admin;
}
{% endif %} {% endif %}
{% if WEB_WEBMAIL != '/' and WEBROOT_REDIRECT != 'none' %} {% if WEB_WEBMAIL != '/' and WEBROOT_REDIRECT != 'none' %}

Loading…
Cancel
Save