MCPcopy
hub / github.com/pallets/flask / run

Method run

src/flask/app.py:546–667  ·  view source on GitHub ↗

Runs the application on a local development server. Do not use ``run()`` in a production setting. It is not intended to meet security and performance requirements for a production server. Instead, see :doc:`/deploying/index` for WSGI server recommendations. If the :

(
        self,
        host: str | None = None,
        port: int | None = None,
        debug: bool | None = None,
        load_dotenv: bool = True,
        **options: t.Any,
    )

Source from the content-addressed store, hash-verified

544 return rv
545
546 def run(
547 self,
548 host: str | None = None,
549 port: int | None = None,
550 debug: bool | None = None,
551 load_dotenv: bool = True,
552 **options: t.Any,
553 ) -> None:
554 """Runs the application on a local development server.
555
556 Do not use ``run()`` in a production setting. It is not intended to
557 meet security and performance requirements for a production server.
558 Instead, see :doc:`/deploying/index` for WSGI server recommendations.
559
560 If the :attr:`debug` flag is set the server will automatically reload
561 for code changes and show a debugger in case an exception happened.
562
563 If you want to run the application in debug mode, but disable the
564 code execution on the interactive debugger, you can pass
565 ``use_evalex=False`` as parameter. This will keep the debugger's
566 traceback screen active, but disable code execution.
567
568 It is not recommended to use this function for development with
569 automatic reloading as this is badly supported. Instead you should
570 be using the :command:`flask` command line script's ``run`` support.
571
572 .. admonition:: Keep in Mind
573
574 Flask will suppress any server error with a generic error page
575 unless it is in debug mode. As such to enable just the
576 interactive debugger without the code reloading, you have to
577 invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
578 Setting ``use_debugger`` to ``True`` without being in debug mode
579 won't catch any exceptions because there won't be any to
580 catch.
581
582 :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
583 have the server available externally as well. Defaults to
584 ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
585 if present.
586 :param port: the port of the webserver. Defaults to ``5000`` or the
587 port defined in the ``SERVER_NAME`` config variable if present.
588 :param debug: if given, enable or disable debug mode. See
589 :attr:`debug`.
590 :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
591 files to set environment variables. Will also change the working
592 directory to the directory containing the first file found.
593 :param options: the options to be forwarded to the underlying Werkzeug
594 server. See :func:`werkzeug.serving.run_simple` for more
595 information.
596
597 .. versionchanged:: 1.0
598 If installed, python-dotenv will be used to load environment
599 variables from :file:`.env` and :file:`.flaskenv` files.
600
601 The :envvar:`FLASK_DEBUG` environment variable will override :attr:`debug`.
602
603 Threaded mode is enabled by default.

Callers 8

test_run_defaultsFunction · 0.80
test_run_server_portFunction · 0.80
test_run_from_configFunction · 0.80
__call__Method · 0.80

Calls 4

get_load_dotenvFunction · 0.85
get_debug_flagFunction · 0.85
setdefaultMethod · 0.80
getMethod · 0.45