From 14b902e7248d0cab190a0ad2b0ef03940ae00dc8 Mon Sep 17 00:00:00 2001 From: Brian Savelkouls Date: Sat, 19 Aug 2023 21:05:22 +0100 Subject: [PATCH 1/3] Increase initialisation spead --- eel/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eel/__init__.py b/eel/__init__.py index fd09b45b..cd5a45e2 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -111,7 +111,7 @@ def decorator(function: Callable[..., Any]) -> Any: def init(path: str, allowed_extensions: List[str] = ['.js', '.html', '.txt', '.htm', - '.xhtml', '.vue'], js_result_timeout: int = 10000) -> None: + '.xhtml', '.vue'], exclude_path: List[str] = [], js_result_timeout: int = 10000) -> None: global root_path, _js_functions, _js_result_timeout root_path = _get_real_path(path) @@ -121,6 +121,10 @@ def init(path: str, allowed_extensions: List[str] = ['.js', '.html', '.txt', '.h if not any(name.endswith(ext) for ext in allowed_extensions): continue + # exclude specific file paths to increase loading speed on initialisation + if any(exclude in os.path.join(root, name) for exclude in exclude_path): + continue + try: with open(os.path.join(root, name), encoding='utf-8') as file: contents = file.read() From fa9c95d2ea2017ed2702d95b50ea87744105ec34 Mon Sep 17 00:00:00 2001 From: Brian Savelkouls Date: Sat, 19 Aug 2023 21:09:57 +0100 Subject: [PATCH 2/3] documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6b70d27d..8ccca624 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ This will start a webserver on the default settings (http://localhost:8000) and If Chrome or Chromium is installed then by default it will open in that in App Mode (with the `--app` cmdline flag), regardless of what the OS's default browser is set to (it is possible to override this behaviour). +If you have alrge amounts of .html or .js files, eel.init() might take up a long time to scan those files for exposed functions. By passing a list of paths to the init function's exclude_path parameter you can exclude these files from being scanned. + ### App options Additional options can be passed to `eel.start()` as keyword arguments. From dfb4ce4a386cdf4597896e8a3fc3e851b9767bc0 Mon Sep 17 00:00:00 2001 From: "B. Savelkouls" <105946622+savelkouls@users.noreply.github.com> Date: Sat, 19 Aug 2023 21:22:24 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ccca624..9fe3eb8d 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ This will start a webserver on the default settings (http://localhost:8000) and If Chrome or Chromium is installed then by default it will open in that in App Mode (with the `--app` cmdline flag), regardless of what the OS's default browser is set to (it is possible to override this behaviour). -If you have alrge amounts of .html or .js files, eel.init() might take up a long time to scan those files for exposed functions. By passing a list of paths to the init function's exclude_path parameter you can exclude these files from being scanned. +If you have large amounts of .html or .js files, eel.init() might take up a long time to scan those files for exposed functions. By passing a list of paths to the init function's exclude_path parameter you can exclude these files from being scanned. ### App options