diff --git a/files/__main__.py b/files/__main__.py index 49de05b05..37695b36a 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -3,7 +3,6 @@ gevent.monkey.patch_all() from os import environ import secrets from flask import * -from flask_assets import Bundle, Environment from flask_caching import Cache from flask_limiter import Limiter from flask_compress import Compress @@ -89,13 +88,6 @@ cache = Cache(app) Compress(app) mail = Mail(app) -assets = Environment(app) -css = Bundle('src/main.css', output='dist/main.css', filters='postcss') - -assets.register('css', css) -css.build() - - @app.before_request def before_request(): diff --git a/files/routes/static.py b/files/routes/static.py index f14ea95c9..e20d847c3 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -247,6 +247,20 @@ def archives(path): if request.path.endswith('.css'): resp.headers.add("Content-Type", "text/css") return resp +@app.get('/static/') +@limiter.exempt +def static_service(path): + resp = make_response(send_from_directory('./static', path)) + if request.path.endswith('.webp') or request.path.endswith('.gif') or request.path.endswith('.ttf') or request.path.endswith('.woff') or request.path.endswith('.woff2'): + resp.headers.remove("Cache-Control") + resp.headers.add("Cache-Control", "public, max-age=2628000") + + if request.path.endswith('.webp'): + resp.headers.remove("Content-Type") + resp.headers.add("Content-Type", "image/webp") + + return resp + @app.get('/assets/') @limiter.exempt def static_service(path): diff --git a/files/templates/default.html b/files/templates/default.html index 50beae64f..a2121fd45 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -188,9 +188,7 @@ - {% assets 'css' %} - - {% endassets %} + diff --git a/files/templates/login.html b/files/templates/login.html index f85667e6d..0b46e7886 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -15,9 +15,7 @@ - {% assets 'css' %} - - {% endassets %} + diff --git a/files/templates/settings.html b/files/templates/settings.html index 2727467d1..af049dbde 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -31,9 +31,7 @@ - {% assets 'css' %} - - {% endassets %} + diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index ca03fd465..a539fa950 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -28,9 +28,7 @@ - {% assets 'css' %} - - {% endassets %} + diff --git a/files/templates/tailwind.html b/files/templates/tailwind.html index ad3d5e30f..4d015ebc2 100644 --- a/files/templates/tailwind.html +++ b/files/templates/tailwind.html @@ -5,9 +5,7 @@ - {% assets 'css' %} - - {% endassets %} + Flask + Tailwind CSS