Repository: Avaiga/taipy
File: taipy/gui/server.py (Python)

Code before:
                "jsx": template_str,
                "style": (style + os.linesep) if style else "",
                "head": head or [],
                "context": context or self._gui._get_default_module_name(),
            }
        )

    def _direct_render_json(self, data):
        return jsonify(data)

    def get_flask(self):
        return self._flask

    def test_client(self):
        return self._flask.test_client()

    def _run_notebook(self):
        self._is_running = True
        self._ws.run(self._flask, host=self._host, port=self._port, debug=False, use_reloader=False)

    def _get_async_mode(self) -> str:
        return self._ws.async_mode

    def _apply_patch(self):
        if self._get_async_mode() == "gevent" and util.find_spec("gevent"):
            from gevent import monkey, get_hub
            get_hub().NOT_ERROR += (KeyboardInterrupt, )
            if not monkey.is_module_patched("time"):
                monkey.patch_time()
        if self._get_async_mode() == "eventlet" and util.find_spec("eventlet"):
            from eventlet import monkey_patch, patcher

            if not patcher.is_monkey_patched("time"):
                monkey_patch(time=True)

    def _get_random_port(self):  # pragma: no cover
        while True:
            port = randint(49152, 65535)
            if port not in _RuntimeManager().get_used_port() and not _is_port_open(self._host, port):
                return port

    def run(self, host, port, debug, use_reloader, flask_log, run_in_thread, allow_unsafe_werkzeug, notebook_proxy):
        host_value = host if host != "0.0.0.0" else "localhost"
        self._host = host
        if port == "auto":
            port = self._get_random_port()
        self._port = port
        if _is_in_notebook() and notebook_proxy:  # pragma: no cover
            from .utils.proxy import NotebookProxy

            # Start proxy if not already started

Review comment (suggestion):
```suggestion
            from gevent import get_hub, monkey

```
for the linter (including the empty line)

Code after:
                "jsx": template_str,
                "style": (style + os.linesep) if style else "",
                "head": head or [],
                "context": context or self._gui._get_default_module_name(),
            }
        )

    def _direct_render_json(self, data):
        return jsonify(data)

    def get_flask(self):
        return self._flask

    def test_client(self):
        return self._flask.test_client()

    def _run_notebook(self):
        self._is_running = True
        self._ws.run(self._flask, host=self._host, port=self._port, debug=False, use_reloader=False)

    def _get_async_mode(self) -> str:
        return self._ws.async_mode

    def _apply_patch(self):
        if self._get_async_mode() == "gevent" and util.find_spec("gevent"):
            from gevent import get_hub, monkey

            get_hub().NOT_ERROR += (KeyboardInterrupt, )
            if not monkey.is_module_patched("time"):
                monkey.patch_time()
        if self._get_async_mode() == "eventlet" and util.find_spec("eventlet"):
            from eventlet import monkey_patch, patcher

            if not patcher.is_monkey_patched("time"):
                monkey_patch(time=True)

    def _get_random_port(self):  # pragma: no cover
        while True:
            port = randint(49152, 65535)
            if port not in _RuntimeManager().get_used_port() and not _is_port_open(self._host, port):
                return port

    def run(self, host, port, debug, use_reloader, flask_log, run_in_thread, allow_unsafe_werkzeug, notebook_proxy):
        host_value = host if host != "0.0.0.0" else "localhost"
        self._host = host
        if port == "auto":
            port = self._get_random_port()
        self._port = port
        if _is_in_notebook() and notebook_proxy:  # pragma: no cover
            from .utils.proxy import NotebookProxy