|
@@ -17,7 +17,10 @@ TEMPLATE = (Path(__file__).parent / 'templates' / 'index.html').read_text()
|
|
|
|
|
|
class Client:
|
|
|
|
|
|
- def __init__(self, dark: Optional[bool] = ...) -> None:
|
|
|
+ def __init__(self,
|
|
|
+ title: Optional[str] = None,
|
|
|
+ dark: Optional[bool] = ...,
|
|
|
+ ) -> None:
|
|
|
self.id = globals.next_client_id
|
|
|
globals.next_client_id += 1
|
|
|
globals.clients[self.id] = self
|
|
@@ -36,6 +39,7 @@ class Client:
|
|
|
|
|
|
self.head_html = ''
|
|
|
self.body_html = ''
|
|
|
+ self.title = title
|
|
|
self.dark = dark
|
|
|
|
|
|
@property
|
|
@@ -54,7 +58,6 @@ class Client:
|
|
|
def build_response(self) -> HTMLResponse:
|
|
|
vue_html, vue_styles, vue_scripts = vue.generate_vue_content()
|
|
|
elements = json.dumps({id: element.to_dict() for id, element in self.elements.items()})
|
|
|
- dark = self.dark if self.dark is not ... else globals.dark
|
|
|
return HTMLResponse(
|
|
|
TEMPLATE
|
|
|
.replace(r'{{ client_id }}', str(self.id))
|
|
@@ -64,7 +67,8 @@ class Client:
|
|
|
.replace(r'{{ body_html | safe }}', f'{self.body_html}\n{vue_html}\n{vue_styles}')
|
|
|
.replace(r'{{ vue_scripts | safe }}', vue_scripts)
|
|
|
.replace(r'{{ js_imports | safe }}', vue.generate_js_imports())
|
|
|
- .replace(r'{{ dark }}', '"auto"' if dark is None else str(dark))
|
|
|
+ .replace(r'{{ title }}', self.title if self.title is not None else globals.title)
|
|
|
+ .replace(r'{{ dark }}', str(self.dark if self.dark is not ... else globals.dark))
|
|
|
)
|
|
|
|
|
|
async def handshake(self, timeout: float = 3.0, check_interval: float = 0.1) -> None:
|