Server
Server(WSGI) creates and listens at the HTTP socket, dispatching the requests to a handler.
WSGIRef server but uses threads to handle requests by using the ThreadingMixIn. This is useful to handle web browsers pre-opening sockets, on which Server would wait indefinitely.
can used with any WSGI compatible web framework
this is a wsgiref based server
wsgiref
is a built-in WSGI package that provides various classes and helpers to develop against WSGI. Mostly it provides a basic WSGI server that can be used for testing or simple demos. WSocket provides support for websocket on wsgiref for testing purpose. It can only initiate connections one at a time, as a result of being single threaded. but WSocket WSGI server is multi threaded HTTP server. So it can handle many connections at a time.
Run
if app not given it runs demo app you can use following values as host
to run local server(named localhost)
"localhost"
"127.0.0.1"
""
default host
is "127.0.0.1".
default port
is 8080. If port is 0, It will choose random port.
default handler_cls
is FixedHandler
(base class of WebsocketHandler)
default server_cls
is ThreadingWSGIServer
app
should be a valid WSGI application. example :
Make Server
Create a new WSGIServer server listening on host and port, accepting connections for app. The return value is an instance of the supplied server_class, and will process requests using the specified handler_class. app must be a WSGI application object, as defined by PEP 3333.
example :
ThreadingWSGIServer
Create a ThreadingWSGIServer instance. server_address should be a (host,port) tuple, and RequestHandlerClass should be the subclass of http.server.BaseHTTPRequestHandler that will be used to process requests.
You do not normally need to call this constructor, as the make_server()
function can handle all the details for you.
ThreadingWSGIServer
is a subclass of WSGIServer
. [ThreadingWSGIServer
] also provides these WSGI-specific methods:
set_app(application)
- Sets the callable application as the WSGI application that will receive requests.
get_app()
- Returns the currently-set application callable.
Normally, however, you do not need to use these additional methods, as [set_app()
] is normally called by make_server()
, and the [get_app()
] exists mainly for the benefit of request handler instances.
Last updated
Was this helpful?