This commit is contained in:
parent
559b4ede76
commit
026d72f29f
@ -15,6 +15,7 @@ package_dir =
|
|||||||
python_requires = >=3.7
|
python_requires = >=3.7
|
||||||
install_requires =
|
install_requires =
|
||||||
aiohttp
|
aiohttp
|
||||||
|
aiohttp-jinja2
|
||||||
dataset
|
dataset
|
||||||
ipython
|
ipython
|
||||||
openai
|
openai
|
||||||
|
@ -4,6 +4,9 @@ import json
|
|||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import aiohttp_jinja2
|
||||||
|
import jinja2
|
||||||
|
|
||||||
import dataset
|
import dataset
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
@ -29,6 +32,7 @@ class BaseApplication(RPCApplication):
|
|||||||
basic_password=None,
|
basic_password=None,
|
||||||
cookie_name=None,
|
cookie_name=None,
|
||||||
session=None,
|
session=None,
|
||||||
|
template_path=None,
|
||||||
*args,
|
*args,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
@ -40,6 +44,7 @@ class BaseApplication(RPCApplication):
|
|||||||
middlewares.append(self.request_middleware)
|
middlewares.append(self.request_middleware)
|
||||||
middlewares.append(self.base64_auth_middleware)
|
middlewares.append(self.base64_auth_middleware)
|
||||||
middlewares.append(self.session_middleware)
|
middlewares.append(self.session_middleware)
|
||||||
|
self.template_path = template_path and template_path or pathlib.Path(__file__).parent / "templates"
|
||||||
self.agents = {}
|
self.agents = {}
|
||||||
super().__init__(middlewares=middlewares, *args, **kwargs)
|
super().__init__(middlewares=middlewares, *args, **kwargs)
|
||||||
|
|
||||||
@ -98,6 +103,9 @@ class BaseApplication(RPCApplication):
|
|||||||
|
|
||||||
return await handler(request)
|
return await handler(request)
|
||||||
|
|
||||||
|
async def render_template(self, name, request, context):
|
||||||
|
return aiohttp_jinja2.render_template(name, request=self.request, context)
|
||||||
|
|
||||||
@web.middleware
|
@web.middleware
|
||||||
async def request_middleware(self, request: web.Request, handler):
|
async def request_middleware(self, request: web.Request, handler):
|
||||||
time_start = time.time()
|
time_start = time.time()
|
||||||
|
Loading…
Reference in New Issue
Block a user