|
@@ -35,7 +35,6 @@ class page:
|
|
|
self.favicon = favicon
|
|
|
self.dark = dark
|
|
|
self.response_timeout = response_timeout
|
|
|
- self.func: Callable
|
|
|
|
|
|
globals.favicons[self.path] = favicon
|
|
|
|
|
@@ -48,13 +47,12 @@ class page:
|
|
|
def __call__(self, func: Callable) -> Callable:
|
|
|
# NOTE we need to remove existing routes for this path to make sure only the latest definition is used
|
|
|
globals.app.routes[:] = [r for r in globals.app.routes if r.path != self.path]
|
|
|
- self.func = func
|
|
|
|
|
|
- async def decorated(*args, **kwargs) -> Response:
|
|
|
+ async def decorated(*dec_args, **dec_kwargs) -> Response:
|
|
|
with Client(self) as client:
|
|
|
if any(p.name == 'client' for p in inspect.signature(func).parameters.values()):
|
|
|
- kwargs['client'] = client
|
|
|
- result = self.create_content(*args, **kwargs)
|
|
|
+ dec_kwargs['client'] = client
|
|
|
+ result = func(*dec_args, **dec_kwargs)
|
|
|
if inspect.isawaitable(result):
|
|
|
async def wait_for_result() -> Response:
|
|
|
with client:
|
|
@@ -76,6 +74,3 @@ class page:
|
|
|
globals.page_routes[decorated] = self.path
|
|
|
|
|
|
return globals.app.get(self.path)(decorated)
|
|
|
-
|
|
|
- def create_content(self, *args, **kwargs) -> None:
|
|
|
- self.func(*args, **kwargs)
|