diff --git a/README.md b/README.md index ec499d5..a709ea6 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ - [DataService Instances (Nested Classes)](#dataservice-instances-nested-classes) - [Custom Components (`pydase.components`)](#custom-components-pydasecomponents) - [`DeviceConnection`](#deviceconnection) + - [Customizing Connection Logic](#customizing-connection-logic) + - [Reconnection Interval](#reconnection-interval) - [`Image`](#image) - [`NumberSlider`](#numberslider) - [`ColouredEnum`](#colouredenum) @@ -30,6 +32,7 @@ - [Customizing the Web Interface](#customizing-the-web-interface) - [Enhancing the Web Interface Style with Custom CSS](#enhancing-the-web-interface-style-with-custom-css) - [Tailoring Frontend Component Layout](#tailoring-frontend-component-layout) + - [Specifying a Custom Frontend Source](#specifying-a-custom-frontend-source) - [Logging in pydase](#logging-in-pydase) - [Changing the Log Level](#changing-the-log-level) - [Documentation](#documentation) @@ -836,6 +839,28 @@ Please ensure that the CSS file path is accessible from the server's running loc The `web_settings.json` file will be stored in the directory specified by `SERVICE_CONFIG_DIR`. You can generate a `web_settings.json` file by setting the `GENERATE_WEB_SETTINGS` to `True`. For more information, see the [configuration section](#configuring-pydase-via-environment-variables). +### Specifying a Custom Frontend Source + +To further personalize your web interface, you can provide `pydase` with a custom frontend GUI. To do so, you can use the `frontend_src` keyword in the `pydase.Server`: + +```python +from pathlib import Path + +import pydase + + +class MyService(pydase.DataService): + # Service definition + + +if __name__ == "__main__": + service = MyService() + pydase.Server( + service, + frontend_src=Path("path/to/your/frontend/directory"), + ).run() +``` + ## Logging in pydase The `pydase` library organizes its loggers on a per-module basis, mirroring the Python package hierarchy. This structured approach allows for granular control over logging levels and behaviour across different parts of the library. diff --git a/src/pydase/server/web_server/web_server.py b/src/pydase/server/web_server/web_server.py index 9969859..4f59c6a 100644 --- a/src/pydase/server/web_server/web_server.py +++ b/src/pydase/server/web_server/web_server.py @@ -70,7 +70,7 @@ class WebServer: enable_cors: bool = True, config_dir: Path = ServiceConfig().config_dir, generate_web_settings: bool = WebServerConfig().generate_web_settings, - **kwargs: Any, + frontend_src: Path = Path(__file__).parent.parent.parent / "frontend", ) -> None: self.observer = data_service_observer self.state_manager = self.observer.state_manager @@ -79,6 +79,7 @@ class WebServer: self.host = host self.css = css self.enable_cors = enable_cors + self.frontend_src = frontend_src self._service_config_dir = config_dir self._generate_web_settings = generate_web_settings self._loop: asyncio.AbstractEventLoop @@ -181,7 +182,7 @@ class WebServer: app.mount( "/", StaticFiles( - directory=Path(__file__).parent.parent.parent / "frontend", + directory=self.frontend_src, html=True, ), )