Fixed a bug where static files would use the last read filetype as mimetype
We need a prettier way of making namespaces
This commit is contained in:
@@ -38,6 +38,9 @@ def listify_output(func):#decorator
|
||||
return list(func(*args, **kwargs))
|
||||
return new_func
|
||||
|
||||
def call(func):#decorator
|
||||
return func()
|
||||
|
||||
class Model:
|
||||
def __setattr__(self, name, value):
|
||||
if not hasattr(self, name):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys, os, airspeed, glob
|
||||
from sanic import Sanic, response
|
||||
from common import withTemplate, withResource
|
||||
from common import withTemplate, withResource, call
|
||||
import card
|
||||
import svg
|
||||
import config
|
||||
@@ -142,18 +142,20 @@ async def svg_add(request, template={}):
|
||||
return response.html(template["svg.vm"].merge(locals()))
|
||||
|
||||
#add static resources:
|
||||
for i in glob.iglob(os.path.join(config.resourcedir, "**","*"), recursive=True):
|
||||
filetype = i.split('.')[-1]
|
||||
if filetype in ("html", "css", "js"):
|
||||
i = os.path.relpath(i, config.resourcedir)
|
||||
print("Adding static resource", repr(i))
|
||||
if filetype == "js": filetype = "javascript"
|
||||
|
||||
@app.get(f"/{i}")
|
||||
@withResource(i)
|
||||
async def card_style(request, file={}):
|
||||
file = tuple(file.values())[0]
|
||||
return response.text(file, headers={"Content-Type": f"text/{filetype}"})
|
||||
for j in glob.iglob(os.path.join(config.resourcedir, "**","*"), recursive=True):
|
||||
@call
|
||||
def temp():#namespace hack
|
||||
filetype = j.split('.')[-1]
|
||||
if filetype in ("html", "css", "js"):
|
||||
i = os.path.relpath(j, config.resourcedir)
|
||||
print("Adding static resource", repr(i))
|
||||
if filetype == "js": filetype = "javascript"
|
||||
|
||||
@app.get(f"/{i}")
|
||||
@withResource(i)
|
||||
async def card_style(request, file={}):
|
||||
file = tuple(file.values())[0]
|
||||
return response.text(file, headers={"Content-Type": f"text/{filetype}"})
|
||||
|
||||
#add svgs:
|
||||
@app.get(f"/svg/<name>.svg")
|
||||
|
||||
Reference in New Issue
Block a user