werkzeug.run_simple¶
-
werkzeug.
run_simple
(hostname, port, application, use_reloader=False, use_debugger=False, use_evalex=True, extra_files=None, reloader_interval=1, reloader_type='auto', threaded=False, processes=1, request_handler=None, static_files=None, passthrough_errors=False, ssl_context=None)[source]¶ 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
New in version 0.5: static_files was added to simplify serving of static files as well as passthrough_errors.
New in version 0.6: support for SSL was added.
New in version 0.8: Added support for automatically loading a SSL context from certificate file and private key.
New in version 0.9: Added command-line interface.
New in version 0.10: Improved the reloader and added support for changing the backend through the reloader_type parameter. See reloader for more information.
Parameters: - hostname – The host for the application. eg:
'localhost'
- port – The port for the server. eg:
8080
- application – the WSGI application to execute
- use_reloader – should the server automatically restart the python process if modules were changed?
- use_debugger – should the werkzeug debugging system be used?
- use_evalex – should the exception evaluation feature be enabled?
- extra_files – a list of files the reloader should watch additionally to the modules. For example configuration files.
- reloader_interval – the interval for the reloader in seconds.
- reloader_type – the type of reloader to use. The default is
auto detection. Valid values are
'stat'
and'watchdog'
. See reloader for more information. - threaded – should the process handle each request in a separate thread?
- processes – if greater than 1 then handle each request in a new process up to this maximum number of concurrent processes.
- request_handler – optional parameter that can be used to replace
the default one. You can use this to replace it
with a different
BaseHTTPRequestHandler
subclass. - static_files – a 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 – 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 – 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, orNone
to disable SSL (which is the default).
- hostname – The host for the application. eg: