mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +02:00
fixes WebServer
This commit is contained in:
parent
c7d63f5139
commit
439f514ea5
@ -62,6 +62,9 @@ class WebServer:
|
|||||||
self.enable_cors = enable_cors
|
self.enable_cors = enable_cors
|
||||||
self._loop: asyncio.AbstractEventLoop
|
self._loop: asyncio.AbstractEventLoop
|
||||||
|
|
||||||
|
async def serve(self) -> None:
|
||||||
|
self._loop = asyncio.get_running_loop()
|
||||||
|
self._setup_socketio()
|
||||||
self._setup_fastapi_app()
|
self._setup_fastapi_app()
|
||||||
self.web_server = uvicorn.Server(
|
self.web_server = uvicorn.Server(
|
||||||
uvicorn.Config(self.__fastapi_app, host=self.host, port=self.port)
|
uvicorn.Config(self.__fastapi_app, host=self.host, port=self.port)
|
||||||
@ -69,13 +72,6 @@ class WebServer:
|
|||||||
# overwrite uvicorn's signal handlers, otherwise it will bogart SIGINT and
|
# overwrite uvicorn's signal handlers, otherwise it will bogart SIGINT and
|
||||||
# SIGTERM, which makes it impossible to escape out of
|
# SIGTERM, which makes it impossible to escape out of
|
||||||
self.web_server.install_signal_handlers = lambda: None # type: ignore[method-assign]
|
self.web_server.install_signal_handlers = lambda: None # type: ignore[method-assign]
|
||||||
|
|
||||||
async def serve(self) -> Any:
|
|
||||||
"""Starts the server. This method should be implemented as an asynchronous
|
|
||||||
method, which means that it should be able to run concurrently with other tasks.
|
|
||||||
"""
|
|
||||||
self._loop = asyncio.get_running_loop()
|
|
||||||
self._setup_socketio()
|
|
||||||
await self.web_server.serve()
|
await self.web_server.serve()
|
||||||
|
|
||||||
def _setup_socketio(self) -> None:
|
def _setup_socketio(self) -> None:
|
||||||
@ -117,7 +113,7 @@ class WebServer:
|
|||||||
app.mount(
|
app.mount(
|
||||||
"/",
|
"/",
|
||||||
StaticFiles(
|
StaticFiles(
|
||||||
directory=Path(__file__).parent.parent / "frontend",
|
directory=Path(__file__).parent.parent.parent / "frontend",
|
||||||
html=True,
|
html=True,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user