This commit is contained in:
Izalia Mae 2021-11-18 13:04:18 -05:00
parent 6b45bb1ff6
commit b798d5504d
5 changed files with 21 additions and 3 deletions

View file

@ -2,7 +2,7 @@
%html
%head
%title << {{cfg.title}}: {{page}}
%link(rel='shortcut icon', type='image/png', href='/framework/static/icon64.png')
%link(rel='shortcut icon', type='image/png', href='{{cfg.tpl_favicon_path}}')
%link(rel='stylesheet' type='text/css' href='/framework/style.css')
%link(rel='manifest' href='/framework/manifest.json')
%meta(charset='UTF-8')

View file

@ -19,6 +19,7 @@ def create_app(appname, **kwargs):
from .application import Application, Blueprint
from .middleware import MediaCacheControl
from .misc import Cookies, Headers
from .request import Request
from .response import Response

View file

@ -34,7 +34,8 @@ class Config(BaseConfig):
tpl_globals = {},
tpl_context = None,
tpl_autoescape = True,
tpl_default = True
tpl_default = True,
tpl_favicon_path = '/framework/static/icon64.png'
)
self._startup = False

View file

@ -7,6 +7,9 @@ from .misc import Cookies, Headers, CookieItem
from ..dotdict import DotDict, MultiDotDict
try: from ..http_signatures import verify_headers
except ImportError: verify_headers = None
UtcTime = timezone.utc
LocalTime = datetime.now(UtcTime).astimezone().tzinfo
@ -195,3 +198,16 @@ class Request:
def new_response(self, *args, **kwargs):
return self.app.cfg.response_class(*args, **kwargs)
async def verify_signature(self, actor):
if not verify_headers:
raise ImportError('Failed to import verify_headers from izzylib.http_signatures.')
return verify_headers(
headers = {k: self.headers.getone(k) for k in request.headers.keys()},
method = self.method,
path = self.path,
actor = actor,
body = await self.body
)

View file

@ -61,7 +61,7 @@ def Static(src):
data = fd.read()
if magic:
mime = magic.from_buffer(data[:2048], mime=True) or mimetypes.guess_type(path)
mime = mimetypes.guess_type(path)[0] or magic.from_buffer(data[:2048], mime=True)
else:
mime = mimetypes.guess_type(path)