|
1 | 1 | """ |
2 | 2 | Flask backend |
3 | 3 | """ |
4 | | -import os |
5 | 4 | import json |
6 | 5 | import logging |
| 6 | +import os |
7 | 7 | import threading |
8 | 8 |
|
| 9 | +import werkzeug |
9 | 10 | from flask import Flask, request, send_from_directory, Response |
10 | 11 |
|
11 | 12 | from . import page |
12 | | -from ..session import Session |
13 | 13 | from .httpbased import HttpContext, HttpHandler, run_event_loop |
14 | | -from .remote_access import start_remote_access_service |
15 | 14 | from .page import make_applications |
| 15 | +from .remote_access import start_remote_access_service |
16 | 16 | from .utils import cdn_validation |
| 17 | +from ..session import Session |
17 | 18 | from ..utils import STATIC_PATH, iscoroutinefunction, isgeneratorfunction |
18 | 19 | from ..utils import get_free_port, parse_file_size |
19 | 20 |
|
@@ -166,12 +167,13 @@ def start_server(applications, port=8080, host='', cdn=True, |
166 | 167 | if not debug: |
167 | 168 | logging.getLogger('werkzeug').setLevel(logging.WARNING) |
168 | 169 |
|
169 | | - if remote_access: |
| 170 | + running_from_reloader = werkzeug.serving.is_running_from_reloader() |
| 171 | + if remote_access and not running_from_reloader: |
170 | 172 | start_remote_access_service(local_port=port) |
171 | 173 |
|
172 | 174 | has_coro_target = any(iscoroutinefunction(target) or isgeneratorfunction(target) for |
173 | 175 | target in make_applications(applications).values()) |
174 | | - if has_coro_target: |
| 176 | + if has_coro_target and not running_from_reloader: |
175 | 177 | threading.Thread(target=run_event_loop, daemon=True).start() |
176 | 178 |
|
177 | | - app.run(host=host, port=port, debug=debug, threaded=True, **flask_options) |
| 179 | + app.run(host=host, port=port, debug=debug, threaded=True, use_evalex=False, **flask_options) |
0 commit comments