Path 1: 25 calls (0.71)

None (25)

None (25)

True (13) False (12)

True (25)

{'use_debugger': True, 'use_reloader': True} (6) {'use_debugger': False, 'use_reloader': True} (6) {'use_debugger': True, 'use_reloader': False} (6) {...

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False
            

Path 2: 3 calls (0.09)

None (3)

None (3)

None (3)

True (3)

{} (3)

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False
            

Path 3: 2 calls (0.06)

None (2)

None (2)

None (2)

True (2)

{} (2)

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False
            

Path 4: 2 calls (0.06)

'localhost' (2)

80 (1) 0 (1)

None (2)

True (2)

{} (2)

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False
            

Path 5: 1 calls (0.03)

'localhost' (1)

8000 (1)

True (1)

True (1)

{} (1)

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False
            

Path 6: 1 calls (0.03)

'localhost' (1)

None (1)

None (1)

True (1)

{} (1)

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False
            

Path 7: 1 calls (0.03)

None (1)

80 (1)

None (1)

True (1)

{} (1)

1def run(
2        self,
3        host: str | None = None,
4        port: int | None = None,
5        debug: bool | None = None,
6        load_dotenv: bool = True,
7        **options: t.Any,
8    ) -> None:
9        """Runs the application on a local development server.
10
11        Do not use ``run()`` in a production setting. It is not intended to
12        meet security and performance requirements for a production server.
13        Instead, see :doc:`/deploying/index` for WSGI server recommendations.
14
15        If the :attr:`debug` flag is set the server will automatically reload
16        for code changes and show a debugger in case an exception happened.
17
18        If you want to run the application in debug mode, but disable the
19        code execution on the interactive debugger, you can pass
20        ``use_evalex=False`` as parameter.  This will keep the debugger's
21        traceback screen active, but disable code execution.
22
23        It is not recommended to use this function for development with
24        automatic reloading as this is badly supported.  Instead you should
25        be using the :command:`flask` command line script's ``run`` support.
26
27        .. admonition:: Keep in Mind
28
29           Flask will suppress any server error with a generic error page
30           unless it is in debug mode.  As such to enable just the
31           interactive debugger without the code reloading, you have to
32           invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
33           Setting ``use_debugger`` to ``True`` without being in debug mode
34           won't catch any exceptions because there won't be any to
35           catch.
36
37        :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
38            have the server available externally as well. Defaults to
39            ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
40            if present.
41        :param port: the port of the webserver. Defaults to ``5000`` or the
42            port defined in the ``SERVER_NAME`` config variable if present.
43        :param debug: if given, enable or disable debug mode. See
44            :attr:`debug`.
45        :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
46            files to set environment variables. Will also change the working
47            directory to the directory containing the first file found.
48        :param options: the options to be forwarded to the underlying Werkzeug
49            server. See :func:`werkzeug.serving.run_simple` for more
50            information.
51
52        .. versionchanged:: 1.0
53            If installed, python-dotenv will be used to load environment
54            variables from :file:`.env` and :file:`.flaskenv` files.
55
56            The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
57
58            Threaded mode is enabled by default.
59
60        .. versionchanged:: 0.10
61            The default port is now picked from the ``SERVER_NAME``
62            variable.
63        """
64        # Ignore this call so that it doesn't start another server if
65        # the 'flask run' command is used.
66        if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
67            if not is_running_from_reloader():
68                click.secho(
69                    " * Ignoring a call to 'app.run()' that would block"
70                    " the current 'flask' CLI command.\n"
71                    "   Only call 'app.run()' in an 'if __name__ =="
72                    ' "__main__"\' guard.',
73                    fg="red",
74                )
75
76            return
77
78        if get_load_dotenv(load_dotenv):
79            cli.load_dotenv()
80
81            # if set, env var overrides existing value
82            if "FLASK_DEBUG" in os.environ:
83                self.debug = get_debug_flag()
84
85        # debug passed to method overrides all other sources
86        if debug is not None:
87            self.debug = bool(debug)
88
89        server_name = self.config.get("SERVER_NAME")
90        sn_host = sn_port = None
91
92        if server_name:
93            sn_host, _, sn_port = server_name.partition(":")
94
95        if not host:
96            if sn_host:
97                host = sn_host
98            else:
99                host = "127.0.0.1"
100
101        if port or port == 0:
102            port = int(port)
103        elif sn_port:
104            port = int(sn_port)
105        else:
106            port = 5000
107
108        options.setdefault("use_reloader", self.debug)
109        options.setdefault("use_debugger", self.debug)
110        options.setdefault("threaded", True)
111
112        cli.show_server_banner(self.debug, self.name)
113
114        from werkzeug.serving import run_simple
115
116        try:
117            run_simple(t.cast(str, host), port, self, **options)
118        finally:
119            # reset the first request information if the development server
120            # reset normally.  This makes it possible to restart the server
121            # without reloader and that stuff from an interactive shell.
122            self._got_first_request = False