-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
5,338 additions
and
12,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"python.pythonPath": "venv/bin/python" | ||
} | ||
"python.formatting.provider": "black" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/*! | ||
* https://github.com/Starcounter-Jack/JSON-Patch | ||
* (c) 2017 Joachim Wester | ||
* MIT license | ||
*/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,48 @@ | ||
import os | ||
from typing import Any, Callable | ||
|
||
from dash import Dash | ||
from flask import Flask, send_from_directory | ||
from idom.widgets.utils import multiview | ||
from idom.client.module import Module | ||
from idom.core.component import AbstractComponent | ||
from idom.config import IDOM_CLIENT_IMPORT_SOURCE_URL, IDOM_CLIENT_BUILD_DIR | ||
from idom.server.flask import PerClientStateServer, Config | ||
from flask import Flask | ||
from idom.config import IDOM_DEBUG_MODE | ||
from idom.widgets import multiview | ||
from idom.core.proto import ComponentType | ||
from idom.server.flask import PerClientStateServer, Config, FlaskServer | ||
from idom import Ref | ||
|
||
from .IdomDashComponent import IdomDashComponent | ||
|
||
|
||
IDOM_DASH_SERVER_BASE_URL = Ref(os.environ.get("IDOM_DASH_SERVER_BASE_URL", "")) | ||
SERVER_CONFIG = Config( | ||
url_prefix="/_idom", | ||
serve_static_files=False, | ||
serve_static_files=True, | ||
redirect_root_to_index=False, | ||
) | ||
IDOM_CLIENT_IMPORT_SOURCE_URL.set("./_idom") | ||
_MOUNT, IdomComponentView = multiview() | ||
_MOUNT_VIEW, IdomComponentView = multiview() | ||
|
||
|
||
def create_component(__constructor: Callable[[], AbstractComponent], *args: Any, **kwargs: Any) -> IdomDashComponent: | ||
view_id = _MOUNT(lambda: __constructor(*args, **kwargs)) | ||
return IdomDashComponent(viewId=view_id, clientModuleUrl=Module("idom-client-react").url) | ||
def create_component( | ||
__constructor: Callable[[], ComponentType], *args: Any, **kwargs: Any | ||
) -> IdomDashComponent: | ||
view_id = _MOUNT_VIEW.add(None, lambda: __constructor(*args, **kwargs)) | ||
return IdomDashComponent(viewId=view_id) | ||
|
||
|
||
def run_server(app: Dash, host: str, port: int, debug: bool = False, *args: Any, **kwargs: Any) -> PerClientStateServer: | ||
if debug: | ||
print(f"Serving at http://{host}:{port}/") | ||
def run_server( | ||
app: Dash, host: str, port: int, *args: Any, **kwargs: Any | ||
) -> PerClientStateServer: | ||
idom_server_extension = _make_render_server(app.server) | ||
idom_server_extension.run(host, port, debug=debug, *args, **kwargs) | ||
idom_server_extension.run(host, port, *args, **kwargs) | ||
return idom_server_extension | ||
|
||
|
||
def run_daemon_server(app: Dash, host: str, port: int, debug: bool = False, *args: Any, **kwargs: Any) -> PerClientStateServer: | ||
if debug: | ||
print(f"Serving at http://{host}:{port}/") | ||
def run_daemon_server( | ||
app: Dash, host: str, port: int, *args: Any, **kwargs: Any | ||
) -> PerClientStateServer: | ||
idom_server_extension = _make_render_server(app.server) | ||
idom_server_extension.daemon(host, port, debug=debug, *args, **kwargs) | ||
idom_server_extension.run_in_thread(host, port, *args, **kwargs) | ||
return idom_server_extension | ||
|
||
def _make_render_server(server: Flask) -> PerClientStateServer: | ||
idom_server_extension = PerClientStateServer(IdomComponentView, SERVER_CONFIG) | ||
idom_server_extension.register(server) | ||
|
||
@server.route(f"{SERVER_CONFIG['url_prefix']}/<path:path>") | ||
def serve_web_modules(path: str): | ||
return send_from_directory(str(IDOM_CLIENT_BUILD_DIR.get()), path) | ||
|
||
return idom_server_extension | ||
def _make_render_server(server: Flask) -> FlaskServer: | ||
return PerClientStateServer(IdomComponentView, SERVER_CONFIG, app=server) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/*! | ||
* https://github.com/Starcounter-Jack/JSON-Patch | ||
* (c) 2017 Joachim Wester | ||
* MIT license | ||
*/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/*! | ||
* https://github.com/Starcounter-Jack/JSON-Patch | ||
* (c) 2017 Joachim Wester | ||
* MIT license | ||
*/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.