A WSGI and HTTP server for use **during development only**. This server is convenient to use, but is not designed to be particularly stable, secure, or efficient. Use a dedicate WSGI server and HTTP server when deploying to production. It provides features like interactive debugging and code reloading. Use ``run_simple`` to start the server. Put this in a ``run.py`` script: .. code-block:: python from myapp import create_app from werkzeug import run_simple
Class |
|
A WSGI server that that handles one request at a time. |
Class |
|
An input stream that handles Transfer-Encoding 'chunked' |
Class |
|
A WSGI server that handles concurrent requests in separate forked processes. |
Class |
|
A WSGI server that handles concurrent requests in separate threads. |
Class |
|
A request handler that implements WSGI dispatching. |
Function | generate |
Generates an adhoc SSL context for the development server. |
Function | generate |
Undocumented |
Function | get |
Get the IP address of an external interface. Used when binding to 0.0.0.0 or ::1 to show a more useful URL. |
Function | get |
Return a fully qualified socket address that can be passed to :func:`socket.bind`. |
Function | is |
Check if the server is running as a subprocess within the Werkzeug reloader. |
Function | is |
Checks if the given error (or the current one) is an SSL error. |
Function | load |
Loads SSL context from cert/private key files and optional protocol. Many parameters are directly taken from the API of :py:class:`ssl.SSLContext`. |
Function | make |
Create an appropriate WSGI server instance based on the value of ``threaded`` and ``processes``. |
Function | make |
Creates an SSL key for development. This should be used instead of the ``'adhoc'`` key which generates a new cert on each server start. It accepts a path for where it should store the key and cert and either a host or CN... |
Function | run |
Start a development server for a WSGI application. Various optional features can be enabled. |
Function | select |
Return ``AF_INET4``, ``AF_INET6``, or ``AF_UNIX`` depending on the host and port. |
Constant | LISTEN |
Undocumented |
Variable | can |
Undocumented |
Function | _ansi |
Undocumented |
Type Alias | _ |
Undocumented |
Variable | _log |
Undocumented |
t.Optional[ str]
= None) -> t.Tuple[ Certificate, RSAPrivateKeyWithSerialization]
:
(source)
¶
Undocumented
Get the IP address of an external interface. Used when binding to 0.0.0.0 or ::1 to show a more useful URL. :meta private:
str
, port: int
, family: socket.AddressFamily
) -> t.Union[ t.Tuple[ str, int], str]
:
(source)
¶
Return a fully qualified socket address that can be passed to :func:`socket.bind`.
str
, pkey_file: t.Optional[ str]
= None, protocol: t.Optional[ int]
= None) -> ssl.SSLContext
:
(source)
¶
Loads SSL context from cert/private key files and optional protocol. Many parameters are directly taken from the API of :py:class:`ssl.SSLContext`. :param cert_file: Path of the certificate to use. :param pkey_file: Path of the private key to use. If not given, the key will be obtained from the certificate file. :param protocol: A ``PROTOCOL`` constant from the :mod:`ssl` module. Defaults to :data:`ssl.PROTOCOL_TLS_SERVER`.
str
, port: int
, app: WSGIApplication
, threaded: bool
= False, processes: int
= 1, request_handler: t.Optional[ t.Type[ WSGIRequestHandler]]
= None, passthrough_errors: bool
= False, ssl_context: t.Optional[ _TSSLContextArg]
= None, fd: t.Optional[ int]
= None) -> BaseWSGIServer
:
(source)
¶
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 docs.
str
, host: t.Optional[ str]
= None, cn: t.Optional[ str]
= None) -> t.Tuple[ str, str]
:
(source)
¶
Creates an SSL key for development. This should be used instead of the ``'adhoc'`` key which generates a new cert on each server start. It accepts a path for where it should store the key and cert and either a host or CN. If a host is given it will use the CN ``*.host/CN=host``. For more information see :func:`run_simple`. .. versionadded:: 0.9 :param base_path: the path to the certificate and key. The extension ``.crt`` is added for the certificate, ``.key`` is added for the key. :param host: the name of the host. This can be used as an alternative for the `cn`. :param cn: the `CN` to use.
str
, port: int
, application: WSGIApplication
, use_reloader: bool
= False, use_debugger: bool
= False, use_evalex: bool
= True, extra_files: t.Optional[ t.Iterable[ str]]
= None, exclude_patterns: t.Optional[ t.Iterable[ str]]
= None, reloader_interval: int
= 1, reloader_type: str
= 'auto', threaded: bool
= False, processes: int
= 1, request_handler: t.Optional[ t.Type[ WSGIRequestHandler]]
= None, static_files: t.Optional[ t.Dict[ str, t.Union[ str, t.Tuple[ str, str]]]]
= None, passthrough_errors: bool
= False, ssl_context: t.Optional[ _TSSLContextArg]
= None):
(source)
¶
Start a development server for a WSGI application. Various optional features can be enabled. .. warning:: Do not use the development server when deploying to production. It is intended for use only during local development. It is not designed to be particularly efficient, stable, or secure. :param hostname: The host to bind to, for example ``'localhost'``. Can be a domain, IPv4 or IPv6 address, or file path starting with ``unix://`` for a Unix socket. :param port: The port to bind to, for example ``8080``. Using ``0`` tells the OS to pick a random free port. :param application: The WSGI application to run. :param use_reloader: Use a reloader process to restart the server process when files are changed. :param use_debugger: Use Werkzeug's debugger, which will show formatted tracebacks on unhandled exceptions. :param use_evalex: Make the debugger interactive. A Python terminal can be opened for any frame in the traceback. Some protection is provided by requiring a PIN, but this should never be enabled on a publicly visible server. :param extra_files: The reloader will watch these files for changes in addition to Python modules. For example, watch a configuration file. :param exclude_patterns: The reloader will ignore changes to any files matching these :mod:`fnmatch` patterns. For example, ignore cache files. :param reloader_interval: How often the reloader tries to check for changes. :param reloader_type: The reloader to use. The ``'stat'`` reloader is built in, but may require significant CPU to watch files. The ``'watchdog'`` reloader is much more efficient but requires installing the ``watchdog`` package first. :param threaded: Handle concurrent requests using threads. Cannot be used with ``processes``. :param processes: Handle concurrent requests using up to this number of processes. Cannot be used with ``threaded``. :param request_handler: Use a different :class:`~BaseHTTPServer.BaseHTTPRequestHandler` subclass to handle requests. :param static_files: A dict mapping URL prefixes to directories to serve static files from using :class:`~werkzeug.middleware.SharedDataMiddleware`. :param passthrough_errors: Don't catch unhandled exceptions at the server level, let the serve crash instead. If ``use_debugger`` is enabled, the debugger will still catch such errors. :param ssl_context: Configure TLS to serve over HTTPS. Can be an :class:`ssl.SSLContext` object, a ``(cert_file, key_file)`` tuple to create a typical context, or the string ``'adhoc'`` to generate a temporary self-signed certificate. .. versionchanged:: 2.1 Instructions are shown for dealing with an "address already in use" error. .. versionchanged:: 2.1 Running on ``0.0.0.0`` or ``::`` shows the loopback IP in addition to a real IP. .. versionchanged:: 2.1 The command-line interface was removed. .. versionchanged:: 2.0 Running on ``0.0.0.0`` or ``::`` shows a real IP address that was bound as well as a warning not to run the development server in production. .. versionchanged:: 2.0 The ``exclude_patterns`` parameter was added. .. versionchanged:: 0.15 Bind to a Unix socket by passing a ``hostname`` that starts with ``unix://``. .. versionchanged:: 0.10 Improved the reloader and added support for changing the backend through the ``reloader_type`` parameter. .. versionchanged:: 0.9 A command-line interface was added. .. versionchanged:: 0.8 ``ssl_context`` can be a tuple of paths to the certificate and private key files. .. versionchanged:: 0.6 The ``ssl_context`` parameter was added. .. versionchanged:: 0.5 The ``static_files`` and ``passthrough_errors`` parameters were added.
Undocumented
Value |
|