diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-01-10 03:20:10 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-01-10 03:20:10 +0300 |
commit | 05c5d18f7619c28e620d42c0921f81ced780cc2d (patch) | |
tree | 26ab7a74daba5d0f37ddb0bbe467e84fdc7fb1b6 /bin/web_kbn.py | |
parent | 54ddea4614dbd31dad577ae5fdb8ec4821490199 (diff) |
save
Diffstat (limited to 'bin/web_kbn.py')
-rw-r--r-- | bin/web_kbn.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/bin/web_kbn.py b/bin/web_kbn.py index e160fde..8b4ca6f 100644 --- a/bin/web_kbn.py +++ b/bin/web_kbn.py @@ -75,27 +75,35 @@ class WebSite(http.HTTPServer): self.app.router.add_static('/assets/', path=homekit_path('web', 'kbn_assets')) - self.get('/', self.get_index) - self.get('/modems', self.get_modems) + self.get('/main.cgi', self.get_index) + self.get('/modems.cgi', self.get_modems) async def render_page(self, req: http.Request, + template_name: str, + title: Optional[str] = None, context: Optional[dict] = None): if context is None: context = {} context = { **context, - 'head_static': get_head_static(), - 'title': 'this is title' + 'head_static': get_head_static() } - response = aiohttp_jinja2.render_template('index.html', req, context=context) + if title is not None: + context['title'] = title + response = aiohttp_jinja2.render_template(template_name+'.j2', req, context=context) return response async def get_index(self, req: http.Request): - return await self.render_page(req) + return await self.render_page(req, 'index', + title="Home web site") async def get_modems(self, req: http.Request): - pass + mc = ModemsConfig() + print(mc) + return await self.render_page(req, 'modems', + title='Состояние модемов', + context=dict(modems=ModemsConfig())) if __name__ == '__main__': |