a
This commit is contained in:
parent
6b45bb1ff6
commit
b798d5504d
|
@ -2,7 +2,7 @@
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%title << {{cfg.title}}: {{page}}
|
%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='stylesheet' type='text/css' href='/framework/style.css')
|
||||||
%link(rel='manifest' href='/framework/manifest.json')
|
%link(rel='manifest' href='/framework/manifest.json')
|
||||||
%meta(charset='UTF-8')
|
%meta(charset='UTF-8')
|
||||||
|
|
|
@ -19,6 +19,7 @@ def create_app(appname, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
from .application import Application, Blueprint
|
from .application import Application, Blueprint
|
||||||
|
from .middleware import MediaCacheControl
|
||||||
from .misc import Cookies, Headers
|
from .misc import Cookies, Headers
|
||||||
from .request import Request
|
from .request import Request
|
||||||
from .response import Response
|
from .response import Response
|
||||||
|
|
|
@ -34,7 +34,8 @@ class Config(BaseConfig):
|
||||||
tpl_globals = {},
|
tpl_globals = {},
|
||||||
tpl_context = None,
|
tpl_context = None,
|
||||||
tpl_autoescape = True,
|
tpl_autoescape = True,
|
||||||
tpl_default = True
|
tpl_default = True,
|
||||||
|
tpl_favicon_path = '/framework/static/icon64.png'
|
||||||
)
|
)
|
||||||
|
|
||||||
self._startup = False
|
self._startup = False
|
||||||
|
|
|
@ -7,6 +7,9 @@ from .misc import Cookies, Headers, CookieItem
|
||||||
|
|
||||||
from ..dotdict import DotDict, MultiDotDict
|
from ..dotdict import DotDict, MultiDotDict
|
||||||
|
|
||||||
|
try: from ..http_signatures import verify_headers
|
||||||
|
except ImportError: verify_headers = None
|
||||||
|
|
||||||
|
|
||||||
UtcTime = timezone.utc
|
UtcTime = timezone.utc
|
||||||
LocalTime = datetime.now(UtcTime).astimezone().tzinfo
|
LocalTime = datetime.now(UtcTime).astimezone().tzinfo
|
||||||
|
@ -195,3 +198,16 @@ class Request:
|
||||||
|
|
||||||
def new_response(self, *args, **kwargs):
|
def new_response(self, *args, **kwargs):
|
||||||
return self.app.cfg.response_class(*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
|
||||||
|
)
|
||||||
|
|
|
@ -61,7 +61,7 @@ def Static(src):
|
||||||
data = fd.read()
|
data = fd.read()
|
||||||
|
|
||||||
if magic:
|
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:
|
else:
|
||||||
mime = mimetypes.guess_type(path)
|
mime = mimetypes.guess_type(path)
|
||||||
|
|
Loading…
Reference in a new issue