Package brisa :: Package core :: Module webserver :: Class WebServer
[hide private]
[frames] | no frames]

Class WebServer

source code

object --+    
         |    
  Resource --+
             |
            WebServer

Webserver class.

Nested Classes [hide private]
  CustomResource
Same as Resource.
  Resource
Represents a resource or a folder on the webserver.
  StaticFile
Object that matches with a file and makes it available on the server.
Instance Methods [hide private]
 
__init__(self, server_name='', host=None, port=None, adapter=None)
WebServer class constructor.
source code
 
set_adapter(self, adapter)
Sets the adapter (even after construction).
source code
 
start(self)
Starts the webserver.
source code
 
stop(self)
Stops the webserver.
source code
string
get_listen_url(self)
Returns the URL currently set to listen on.
source code
tuple
get_bind_address(self)
Returns the address currently bind to.
source code
 
set_bind_address(self, host, port)
Sets the listening url, if it is usable.
source code
string
get_host(self)
Returns the hostname of the URL currently set to listen on.
source code
int
get_port(self)
Returns the port of the URL currently set to listen on.
source code
 
is_running(self)
Returns True if the webserver is running, False otherwise.
source code
bool
check_url(self, host, port)
Returns True if the webserver will be able to listen on this URL, False otherwise.
source code
 
_generate_random_address(self) source code

Inherited from Resource: add_resource, add_static_file, application, get_render, render

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  msg_already_started = 'tried to start() WebServer when already...
  msg_already_stopped = 'tried to stop() WebServer when already ...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, server_name='', host=None, port=None, adapter=None)
(Constructor)

source code 

WebServer class constructor.

Parameters:
  • server_name (string) - server name
  • host (string) - host to listen on
  • port (int) - port to listen on
  • adapter (AdapterInterface) - optional, can receive an adapter retrieved with get_available_adapters()
Overrides: object.__init__

Note: the only parameter that should be always passed is the server name. In most case scenarios, the others can be guessed/assigned automatically by the webserver.

set_adapter(self, adapter)

source code 

Sets the adapter (even after construction).

Do not call this after the webserver is started.

get_bind_address(self)

source code 

Returns the address currently bind to.

Returns: tuple
address (host, port)

get_host(self)

source code 

Returns the hostname of the URL currently set to listen on.

Returns: string
host

get_port(self)

source code 

Returns the port of the URL currently set to listen on.

Returns: int
port

check_url(self, host, port)

source code 

Returns True if the webserver will be able to listen on this URL, False otherwise.

Parameters:
  • host (string) - host
  • port (int) - port
Returns: bool
if the URL is usable

Class Variable Details [hide private]

msg_already_started

Value:
'tried to start() WebServer when already started'

msg_already_stopped

Value:
'tried to stop() WebServer when already stopped'