MCPcopy Create free account
hub / github.com/pallets/flask / run_command

Function run_command

src/flask/cli.py:941–999  ·  view source on GitHub ↗

Run a local development server. This server is for development purposes only. It does not provide the stability, security, or performance of production WSGI servers. The reloader and debugger are enabled by default with the '--debug' option.

(
    info: ScriptInfo,
    host: str,
    port: int,
    reload: bool,
    debugger: bool,
    with_threads: bool,
    cert: ssl.SSLContext | tuple[str, str | None] | t.Literal["adhoc"] | None,
    extra_files: list[str] | None,
    exclude_patterns: list[str] | None,
)

Source from the content-addressed store, hash-verified

939)
940@pass_script_info
941def run_command(
942 info: ScriptInfo,
943 host: str,
944 port: int,
945 reload: bool,
946 debugger: bool,
947 with_threads: bool,
948 cert: ssl.SSLContext | tuple[str, str | None] | t.Literal["adhoc"] | None,
949 extra_files: list[str] | None,
950 exclude_patterns: list[str] | None,
951) -> None:
952 """Run a local development server.
953
954 This server is for development purposes only. It does not provide
955 the stability, security, or performance of production WSGI servers.
956
957 The reloader and debugger are enabled by default with the '--debug'
958 option.
959 """
960 try:
961 app: WSGIApplication = info.load_app() # pyright: ignore
962 except Exception as e:
963 if is_running_from_reloader():
964 # When reloading, print out the error immediately, but raise
965 # it later so the debugger or server can handle it.
966 traceback.print_exc()
967 err = e
968
969 def app(
970 environ: WSGIEnvironment, start_response: StartResponse
971 ) -> cabc.Iterable[bytes]:
972 raise err from None
973
974 else:
975 # When not reloading, raise the error immediately so the
976 # command fails.
977 raise e from None
978
979 debug = get_debug_flag()
980
981 if reload is None:
982 reload = debug
983
984 if debugger is None:
985 debugger = debug
986
987 show_server_banner(debug, info.app_import_path)
988
989 run_simple(
990 host,
991 port,
992 app,
993 use_reloader=reload,
994 use_debugger=debugger,
995 threaded=with_threads,
996 ssl_context=cert,
997 extra_files=extra_files,
998 exclude_patterns=exclude_patterns,

Callers

nothing calls this directly

Calls 3

get_debug_flagFunction · 0.85
show_server_bannerFunction · 0.85
load_appMethod · 0.80

Tested by

no test coverage detected