|
@@ -2,7 +2,7 @@ import multiprocessing
|
|
import os
|
|
import os
|
|
import sys
|
|
import sys
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
-from typing import Any, List, Literal, Optional, Tuple, Union
|
|
|
|
|
|
+from typing import Any, List, Literal, Optional, Tuple, TypedDict, Union
|
|
|
|
|
|
from starlette.routing import Route
|
|
from starlette.routing import Route
|
|
from uvicorn.main import STARTUP_FAILURE
|
|
from uvicorn.main import STARTUP_FAILURE
|
|
@@ -21,6 +21,28 @@ from .server import CustomServerConfig, Server
|
|
APP_IMPORT_STRING = 'nicegui:app'
|
|
APP_IMPORT_STRING = 'nicegui:app'
|
|
|
|
|
|
|
|
|
|
|
|
+class ContactDict(TypedDict):
|
|
|
|
+ name: Optional[str]
|
|
|
|
+ url: Optional[str]
|
|
|
|
+ email: Optional[str]
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class LicenseInfoDict(TypedDict):
|
|
|
|
+ name: str
|
|
|
|
+ identifier: Optional[str]
|
|
|
|
+ url: Optional[str]
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class DocsConfig(TypedDict):
|
|
|
|
+ title: Optional[str]
|
|
|
|
+ summary: Optional[str]
|
|
|
|
+ description: Optional[str]
|
|
|
|
+ version: Optional[str]
|
|
|
|
+ terms_of_service: Optional[str]
|
|
|
|
+ contact: Optional[ContactDict]
|
|
|
|
+ license_info: Optional[LicenseInfoDict]
|
|
|
|
+
|
|
|
|
+
|
|
def run(*,
|
|
def run(*,
|
|
host: Optional[str] = None,
|
|
host: Optional[str] = None,
|
|
port: Optional[int] = None,
|
|
port: Optional[int] = None,
|
|
@@ -31,7 +53,7 @@ def run(*,
|
|
language: Language = 'en-US',
|
|
language: Language = 'en-US',
|
|
binding_refresh_interval: float = 0.1,
|
|
binding_refresh_interval: float = 0.1,
|
|
reconnect_timeout: float = 3.0,
|
|
reconnect_timeout: float = 3.0,
|
|
- fastapi_docs: bool = False,
|
|
|
|
|
|
+ fastapi_docs: Union[bool, DocsConfig] = False,
|
|
show: bool = True,
|
|
show: bool = True,
|
|
on_air: Optional[Union[str, Literal[True]]] = None,
|
|
on_air: Optional[Union[str, Literal[True]]] = None,
|
|
native: bool = False,
|
|
native: bool = False,
|
|
@@ -64,7 +86,7 @@ def run(*,
|
|
:param language: language for Quasar elements (default: `'en-US'`)
|
|
:param language: language for Quasar elements (default: `'en-US'`)
|
|
:param binding_refresh_interval: time between binding updates (default: `0.1` seconds, bigger is more CPU friendly)
|
|
:param binding_refresh_interval: time between binding updates (default: `0.1` seconds, bigger is more CPU friendly)
|
|
:param reconnect_timeout: maximum time the server waits for the browser to reconnect (default: 3.0 seconds)
|
|
:param reconnect_timeout: maximum time the server waits for the browser to reconnect (default: 3.0 seconds)
|
|
- :param fastapi_docs: whether to enable FastAPI's automatic documentation with Swagger UI, ReDoc, and OpenAPI JSON (default: `False`)
|
|
|
|
|
|
+ :param fastapi_docs: enable FastAPI's automatic documentation with Swagger UI, ReDoc, and OpenAPI JSON (bool or dictionary as described `here<https://fastapi.tiangolo.com/tutorial/metadata/>`_, default: `False`)
|
|
:param show: automatically open the UI in a browser tab (default: `True`)
|
|
:param show: automatically open the UI in a browser tab (default: `True`)
|
|
:param on_air: tech preview: `allows temporary remote access <https://nicegui.io/documentation/section_configuration_deployment#nicegui_on_air>`_ if set to `True` (default: disabled)
|
|
:param on_air: tech preview: `allows temporary remote access <https://nicegui.io/documentation/section_configuration_deployment#nicegui_on_air>`_ if set to `True` (default: disabled)
|
|
:param native: open the UI in a native window of size 800x600 (default: `False`, deactivates `show`, automatically finds an open port)
|
|
:param native: open the UI in a native window of size 800x600 (default: `False`, deactivates `show`, automatically finds an open port)
|
|
@@ -113,6 +135,16 @@ def run(*,
|
|
core.app.redoc_url = '/redoc'
|
|
core.app.redoc_url = '/redoc'
|
|
if not core.app.openapi_url:
|
|
if not core.app.openapi_url:
|
|
core.app.openapi_url = '/openapi.json'
|
|
core.app.openapi_url = '/openapi.json'
|
|
|
|
+ if isinstance(fastapi_docs, dict):
|
|
|
|
+ core.app.title = fastapi_docs.get('title') or title
|
|
|
|
+ core.app.summary = fastapi_docs.get('summary')
|
|
|
|
+ core.app.description = fastapi_docs.get('description') or ''
|
|
|
|
+ core.app.version = fastapi_docs.get('version') or '0.1.0'
|
|
|
|
+ core.app.terms_of_service = fastapi_docs.get('terms_of_service')
|
|
|
|
+ contact = fastapi_docs.get('contact')
|
|
|
|
+ license_info = fastapi_docs.get('license_info')
|
|
|
|
+ core.app.contact = dict(contact) if contact else None
|
|
|
|
+ core.app.license_info = dict(license_info) if license_info else None
|
|
core.app.setup()
|
|
core.app.setup()
|
|
|
|
|
|
if on_air:
|
|
if on_air:
|