28 lines
697 B
Python
28 lines
697 B
Python
from django.http import HttpResponse
|
|
from django.urls import path
|
|
from django.views.decorators.cache import cache_control
|
|
|
|
from tblog.settings import STATIC_DIR
|
|
|
|
|
|
def get_static_serve(path: str, content_type: str):
|
|
def x(request):
|
|
return HttpResponse(
|
|
open(STATIC_DIR / path, "rb").read(),
|
|
content_type=content_type
|
|
)
|
|
|
|
x.__name__ = path
|
|
return x
|
|
|
|
file_associations = {
|
|
"css": "text/css",
|
|
"js": "text/javascript"
|
|
}
|
|
|
|
urlpatterns = [path(i, cache_control(**{"max-age": 60 * 60 * 24 * 30})(get_static_serve(i, file_associations[i.split(".")[-1]]))) for i in [
|
|
"css/ace.css",
|
|
"css/blog.css",
|
|
"css/write.css",
|
|
"js/write.js"
|
|
]]
|