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:
from myapp import create_app from werkzeug import run_simple
Class | BaseWSGIServer |
Simple single-threaded, single-process WSGI server. |
Class | DechunkedInput |
An input stream that handles Transfer-Encoding 'chunked' |
Class | ForkingWSGIServer |
A WSGI server that does forking. |
Class | ThreadedWSGIServer |
A WSGI server that does threading. |
Class | WSGIRequestHandler |
A request handler that implements WSGI dispatching. |
Function | generate_adhoc_ssl_context |
Generates an adhoc SSL context for the development server. |
Function | generate_adhoc_ssl_pair |
Undocumented |
Function | get_interface_ip |
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_sockaddr |
Return a fully qualified socket address that can be passed to socket.bind . |
Function | is_running_from_reloader |
Checks if the application is running from within the Werkzeug reloader subprocess. |
Function | is_ssl_error |
Checks if the given error (or the current one) is an SSL error. |
Function | load_ssl_context |
Loads SSL context from cert/private key files and optional protocol. Many parameters are directly taken from the API of ssl.SSLContext . |
Function | main |
A simple command-line interface for run_simple . |
Function | make_server |
Create a new server instance that is either threaded, or forks or just processes one request after another. |
Function | make_ssl_devcert |
No summary |
Function | run_simple |
Start a WSGI application. Optional features include a reloader, multithreading and fork support. |
Function | run_with_reloader |
Run a process with the reloader. This is not a public API, do not use this function. |
Function | select_address_family |
Return AF_INET4, AF_INET6, or AF_UNIX depending on the host and port. |
Constant | LISTEN_QUEUE |
Undocumented |
Variable | af_unix |
Undocumented |
Variable | can_fork |
Undocumented |
Variable | can_open_by_fd |
Undocumented |
Variable | ssl |
Undocumented |
Class | _SslDummy |
Undocumented |
Function | _ansi_style |
Undocumented |
Variable | _log_add_style |
Undocumented |
Variable | _TSSLContextArg |
Undocumented |
Returns | |
ssl.SSLContext | Undocumented |
Undocumented
Parameters | |
cn:t.Optional[ | Undocumented |
Returns | |
t.Tuple[ | Undocumented |
Parameters | |
family:socket.AddressFamily | Undocumented |
Returns | |
str | Undocumented |
Unknown Field: meta | |
private |
socket.bind
.Parameters | |
host:str | Undocumented |
port:int | Undocumented |
family:socket.AddressFamily | Undocumented |
Returns | |
t.Union[ | Undocumented |
Checks if the application is running from within the Werkzeug reloader subprocess.
Returns | |
bool | Undocumented |
Parameters | |
error:t.Optional[ | Undocumented |
Returns | |
bool | Undocumented |
ssl.SSLContext
.Parameters | |
cert_file:str | Path of the certificate to use. |
pkey_file:t.Optional[ | Path of the private key to use. If not given, the key will be obtained from the certificate file. |
protocol:t.Optional[ | A PROTOCOL constant from the ssl module.
Defaults to ssl.PROTOCOL_TLS_SERVER . |
Returns | |
ssl.SSLContext | Undocumented |
Parameters | |
host:str | Undocumented |
port:int | Undocumented |
app:WSGIApplication | Undocumented |
threaded:bool | Undocumented |
processes:int | Undocumented |
request_handler:t.Optional[ | Undocumented |
passthrough_errors:bool | Undocumented |
ssl_context:t.Optional[ | Undocumented |
fd:t.Optional[ | Undocumented |
Returns | |
BaseWSGIServer | Undocumented |
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 run_simple
.
Parameters | |
base_path:str | the path to the certificate and key. The extension .crt is added for the certificate, .key is added for the key. |
host:t.Optional[ | the name of the host. This can be used as an alternative
for the cn . |
cn:t.Optional[ | the CN to use. |
Returns | |
t.Tuple[ | Undocumented |
Start a WSGI application. Optional features include a reloader, multithreading and fork support.
This function has a command-line interface too:
python -m werkzeug.serving --help
static_files
was added to simplify serving of static files as well
as passthrough_errors
.reloader_type
parameter. See :ref:`reloader`
for more information.Parameters | |
hostname:str | The host to bind to, for example 'localhost'. If the value is a path that starts with unix:// it will bind to a Unix socket instead of a TCP socket.. |
port:int | The port for the server. eg: 8080 |
application:WSGIApplication | the WSGI application to execute |
use_reloader:bool | should the server automatically restart the python process if modules were changed? |
use_debugger:bool | should the werkzeug debugging system be used? |
use_evalex:bool | should the exception evaluation feature be enabled? |
extra_files:t.Optional[ | a list of files the reloader should watch additionally to the modules. For example configuration files. |
exclude_patterns:t.Optional[ | List of fnmatch patterns to ignore
when running the reloader. For example, ignore cache files that
shouldn't reload when updated. |
reloader_interval:int | the interval for the reloader in seconds. |
reloader_type:str | the type of reloader to use. The default is auto detection. Valid values are 'stat' and 'watchdog'. See :ref:`reloader` for more information. |
threaded:bool | should the process handle each request in a separate thread? |
processes:int | if greater than 1 then handle each request in a new process up to this maximum number of concurrent processes. |
request_handler:t.Optional[ | optional parameter that can be used to replace
the default one. You can use this to replace it
with a different
~BaseHTTPServer.BaseHTTPRequestHandler
subclass. |
static_files:t.Optional[ | a list or dict of paths for static files. This works
exactly like SharedDataMiddleware , it's actually
just wrapping the application in that middleware before
serving. |
passthrough_errors:bool | set this to True to disable the error catching.
This means that the server will die on errors but
it can be useful to hook debuggers in (pdb etc.) |
ssl_context:t.Optional[ | an SSL context for the connection. Either an
ssl.SSLContext , a tuple in the form
(cert_file, pkey_file), the string 'adhoc' if
the server should automatically create one, or None
to disable SSL (which is the default). |
Run a process with the reloader. This is not a public API, do not use this function.
Parameters | |
*args:t.Any | Undocumented |
**kwargs:t.Any | Undocumented |
Parameters | |
host:str | Undocumented |
port:int | Undocumented |
Returns | |
socket.AddressFamily | Undocumented |