|
17 | 17 | Request,
|
18 | 18 | copy_current_request_context,
|
19 | 19 | request,
|
20 |
| - send_from_directory, |
| 20 | + send_file, |
21 | 21 | )
|
22 | 22 | from flask_cors import CORS
|
23 | 23 | from flask_sock import Sock
|
24 | 24 | from simple_websocket import Server as WebSocket
|
25 | 25 | from werkzeug.serving import BaseWSGIServer, make_server
|
26 | 26 |
|
27 | 27 | import idom
|
28 |
| -from idom.config import IDOM_WEB_MODULES_DIR |
29 | 28 | from idom.core.hooks import Context, create_context, use_context
|
30 | 29 | from idom.core.layout import LayoutEvent, LayoutUpdate
|
31 | 30 | from idom.core.serve import serve_json_patch
|
32 | 31 | from idom.core.types import ComponentType, RootComponentConstructor
|
33 | 32 | from idom.utils import Ref
|
34 | 33 |
|
35 |
| -from .utils import CLIENT_BUILD_DIR, client_build_dir_path |
| 34 | +from .utils import safe_client_build_dir_path, safe_web_modules_dir_path |
36 | 35 |
|
37 | 36 |
|
38 | 37 | logger = logging.getLogger(__name__)
|
@@ -159,18 +158,15 @@ def _setup_common_routes(blueprint: Blueprint, options: Options) -> None:
|
159 | 158 | @blueprint.route("/")
|
160 | 159 | @blueprint.route("/<path:path>")
|
161 | 160 | def send_client_dir(path: str = "") -> Any:
|
162 |
| - return send_from_directory( |
163 |
| - str(CLIENT_BUILD_DIR), |
164 |
| - client_build_dir_path(path), |
165 |
| - ) |
| 161 | + return send_file(safe_client_build_dir_path(path)) |
166 | 162 |
|
167 | 163 | @blueprint.route(r"/_api/modules/<path:path>")
|
168 | 164 | @blueprint.route(r"<path:_>/_api/modules/<path:path>")
|
169 | 165 | def send_modules_dir(
|
170 | 166 | path: str,
|
171 | 167 | _: str = "", # this is not used
|
172 | 168 | ) -> Any:
|
173 |
| - return send_from_directory(str(IDOM_WEB_MODULES_DIR.current), path) |
| 169 | + return send_file(safe_web_modules_dir_path(path)) |
174 | 170 |
|
175 | 171 |
|
176 | 172 | def _setup_single_view_dispatcher_route(
|
@@ -258,7 +254,7 @@ def run_send() -> None:
|
258 | 254 | dispatch_thread_info.dispatch_loop.call_soon_threadsafe(
|
259 | 255 | dispatch_thread_info.async_recv_queue.put_nowait, value
|
260 | 256 | )
|
261 |
| - finally: |
| 257 | + finally: # pragma: no cover |
262 | 258 | dispatch_thread_info.dispatch_loop.call_soon_threadsafe(
|
263 | 259 | dispatch_thread_info.dispatch_future.cancel
|
264 | 260 | )
|
|
0 commit comments