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