MCPcopy
hub / github.com/pallets/werkzeug / make_server

Function make_server

src/werkzeug/serving.py:907–949  ·  view source on GitHub ↗

Create an appropriate WSGI server instance based on the value of ``threaded`` and ``processes``. This is called from :func:`run_simple`, but can be used separately to have access to the server object, such as to run it in a separate thread. See :func:`run_simple` for parameter

(
    host: str,
    port: int,
    app: WSGIApplication,
    threaded: bool = False,
    processes: int = 1,
    request_handler: type[WSGIRequestHandler] | None = None,
    passthrough_errors: bool = False,
    ssl_context: _TSSLContextArg | None = None,
    fd: int | None = None,
)

Source from the content-addressed store, hash-verified

905
906
907def make_server(
908 host: str,
909 port: int,
910 app: WSGIApplication,
911 threaded: bool = False,
912 processes: int = 1,
913 request_handler: type[WSGIRequestHandler] | None = None,
914 passthrough_errors: bool = False,
915 ssl_context: _TSSLContextArg | None = None,
916 fd: int | None = None,
917) -> BaseWSGIServer:
918 """Create an appropriate WSGI server instance based on the value of
919 ``threaded`` and ``processes``.
920
921 This is called from :func:`run_simple`, but can be used separately
922 to have access to the server object, such as to run it in a separate
923 thread.
924
925 See :func:`run_simple` for parameter docs.
926 """
927 if threaded and processes > 1:
928 raise ValueError("Cannot have a multi-thread and multi-process server.")
929
930 if threaded:
931 return ThreadedWSGIServer(
932 host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
933 )
934
935 if processes > 1:
936 return ForkingWSGIServer(
937 host,
938 port,
939 app,
940 processes,
941 request_handler,
942 passthrough_errors,
943 ssl_context,
944 fd=fd,
945 )
946
947 return BaseWSGIServer(
948 host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
949 )
950
951
952def is_running_from_reloader() -> bool:

Callers 1

run_simpleFunction · 0.85

Calls 3

ThreadedWSGIServerClass · 0.85
ForkingWSGIServerClass · 0.85
BaseWSGIServerClass · 0.85

Tested by

no test coverage detected