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