move routes into the proper python src file
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
from inverter_base import InverterBase
|
||||
from quart import render_template
|
||||
from quart_babel import format_datetime
|
||||
from infos import Infos
|
||||
|
||||
from . import web
|
||||
|
||||
|
||||
def _get_device_icon(client_mode: bool):
|
||||
@@ -59,3 +64,19 @@ def get_table_data():
|
||||
table['tbody'].append(_get_row(inverter))
|
||||
|
||||
return table
|
||||
|
||||
|
||||
@web.route('/data-fetch')
|
||||
async def data_fetch():
|
||||
data = {
|
||||
"update-time": format_datetime(format="medium"),
|
||||
"server-cnt": f"<h3>{Infos.get_counter('ServerMode_Cnt')}</h3>",
|
||||
"client-cnt": f"<h3>{Infos.get_counter('ClientMode_Cnt')}</h3>",
|
||||
"proxy-cnt": f"<h3>{Infos.get_counter('ProxyMode_Cnt')}</h3>",
|
||||
"emulation-cnt": f"<h3>{Infos.get_counter('EmuMode_Cnt')}</h3>",
|
||||
}
|
||||
data["conn-table"] = await render_template('conn_table.html.j2',
|
||||
table=get_table_data())
|
||||
|
||||
data["notes-list"] = await render_template('notes_list.html.j2')
|
||||
return data
|
||||
|
||||
15
app/src/web/pages.py
Normal file
15
app/src/web/pages.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from quart import render_template, url_for
|
||||
|
||||
from . import web
|
||||
|
||||
|
||||
@web.route('/')
|
||||
async def index():
|
||||
return await render_template(
|
||||
'index.html.j2',
|
||||
fetch_url='.'+url_for('web.data_fetch'))
|
||||
|
||||
|
||||
@web.route('/page')
|
||||
async def empty():
|
||||
return await render_template('empty.html.j2')
|
||||
@@ -1,11 +1,9 @@
|
||||
from quart import render_template, url_for
|
||||
from quart import send_from_directory
|
||||
from quart_babel import format_datetime
|
||||
from infos import Infos
|
||||
from web.conn_table import get_table_data
|
||||
from . import web
|
||||
import os
|
||||
|
||||
from quart import send_from_directory
|
||||
|
||||
from . import web
|
||||
|
||||
|
||||
async def get_icon(file: str, mime: str = 'image/png'):
|
||||
return await send_from_directory(
|
||||
@@ -14,34 +12,6 @@ async def get_icon(file: str, mime: str = 'image/png'):
|
||||
mimetype=mime)
|
||||
|
||||
|
||||
@web.route('/')
|
||||
async def index():
|
||||
return await render_template(
|
||||
'index.html.j2',
|
||||
fetch_url='.'+url_for('web.data_fetch'))
|
||||
|
||||
|
||||
@web.route('/page')
|
||||
async def empty():
|
||||
return await render_template('empty.html.j2')
|
||||
|
||||
|
||||
@web.route('/data-fetch')
|
||||
async def data_fetch():
|
||||
data = {
|
||||
"update-time": format_datetime(format="medium"),
|
||||
"server-cnt": f"<h3>{Infos.get_counter('ServerMode_Cnt')}</h3>",
|
||||
"client-cnt": f"<h3>{Infos.get_counter('ClientMode_Cnt')}</h3>",
|
||||
"proxy-cnt": f"<h3>{Infos.get_counter('ProxyMode_Cnt')}</h3>",
|
||||
"emulation-cnt": f"<h3>{Infos.get_counter('EmuMode_Cnt')}</h3>",
|
||||
}
|
||||
data["conn-table"] = await render_template('conn_table.html.j2',
|
||||
table=get_table_data())
|
||||
|
||||
data["notes-list"] = await render_template('notes_list.html.j2')
|
||||
return data
|
||||
|
||||
|
||||
@web.route('/favicon-96x96.png')
|
||||
async def favicon():
|
||||
return await get_icon('favicon-96x96.png')
|
||||
|
||||
Reference in New Issue
Block a user