forked from rDrama/rDrama
1
0
Fork 0

fdsfdsfds

master
Aevann1 2021-12-13 23:52:17 +02:00
parent 7ae88fd99e
commit 799fb8f9c9
7 changed files with 19 additions and 23 deletions

View File

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

View File

@ -247,6 +247,20 @@ def archives(path):
if request.path.endswith('.css'): resp.headers.add("Content-Type", "text/css")
return resp
@app.get('/static/<path:path>')
@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/<path:path>')
@limiter.exempt
def static_service(path):

View File

@ -188,9 +188,7 @@
<link rel="stylesheet" href="/assets/css/main.css?v=203">
{% assets 'css' %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
<link rel="stylesheet" href="/static/dist.css">
<link rel="stylesheet" href="/assets/css/mistletoe.css?v=200">

View File

@ -15,9 +15,7 @@
<link rel="stylesheet" href="/assets/css/main.css?v=200">
{% assets 'css' %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
<link rel="stylesheet" href="/static/dist.css">
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>

View File

@ -31,9 +31,7 @@
<link rel="stylesheet" href="/assets/css/main.css?v=200">
{% assets 'css' %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
<link rel="stylesheet" href="/static/dist.css">
<link rel="stylesheet" href="/assets/css/mistletoe.css?v=200">

View File

@ -28,9 +28,7 @@
<link rel="stylesheet" href="/assets/css/main.css?v=200">
{% assets 'css' %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
<link rel="stylesheet" href="/static/dist.css">
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>

View File

@ -5,9 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% assets 'css' %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
<link rel="stylesheet" href="/static/dist.css">
<title>Flask + Tailwind CSS</title>
</head>