* setup logger for hypercorn and dashboard * use logger.ini to setup dashboard logger * workaround: restore the hypercorn logger config - quart/hyercorn overwrites the logger config. as a workaround we restore the config at the beginning of a request * fix the hypercorn log handler only once * change proxy into a ASGI application - move Quart init from server.py into app.py - create Server class for config and loggin setup - restore hypercorn logging configuration after start of Quart/Hypercorn * move get_log_level into Server class * define config in test_emu_init_close * remove Web() instance from the testcase - with importing app.py The blueprint Web() will automatically created and a second call in test- cases must avoided * add unit tests * move code from app.py into server.py * test the init_logging_system() method * add HypercornLogHndl tests * fix deprecated pytest async warning - Cleanup pending async tasks - fix deprecated warning about event_loop * add unit test for error handling in build_config() * coverage: ignore quart template files * check print output in test_save_and_restore * update changelog
33 lines
850 B
Python
33 lines
850 B
Python
'''Quart blueprint for the proxy webserver with the dashboard
|
|
|
|
Usage:
|
|
app = Quart(__name__, ...)
|
|
Web(app)
|
|
'''
|
|
from quart import Quart, Blueprint
|
|
from quart_babel import Babel
|
|
from utils import load_modules
|
|
|
|
web = Blueprint('web', __name__)
|
|
|
|
load_modules(__loader__)
|
|
|
|
|
|
class Web:
|
|
'''Helper Class to register the Blueprint at Quart and
|
|
initializing Babel'''
|
|
def __init__(self,
|
|
app: Quart,
|
|
translation_directories: str | list[str],
|
|
rel_urls: bool):
|
|
web.build_relative_urls = rel_urls
|
|
app.register_blueprint(web)
|
|
|
|
from .i18n import get_locale, get_tz
|
|
global babel
|
|
babel = Babel(
|
|
app,
|
|
locale_selector=get_locale,
|
|
timezone_selector=get_tz,
|
|
default_translation_directories=translation_directories)
|