CommunicateApp

class pycommunicate.server.app.communicate.CommunicateApp(self, web_port=8080, host='localhost', debug=False, maximum_handler_threads=10000, template_directory="templates")

This is the main app instance, used to create and run a pycommunicate server. Its arguments are for configuration

Parameters:
  • web_port (int) – The port to host the server on
  • host (str) – The hostname to host on
  • debug (bool) – Run with the debug server, never user in production
  • maximum_handler_threads (int) – The size of the handler event pool. This may be removed in the future
  • template_directory (str) – Relative path to the templates
set_secret_key(key)

Sets the internal secret key

Danger

The secret key must be kept secret, for a truly random key use os.urandom()

Parameters:key (str) – The new secret key
add_controller(route, controller)

Associates a ControllerFactory with a route.

Warning

Any route starting with __pycommunicate/ will not work, as this path is reserved for pycommunicate’s internal routes.

Tip

Routes can contain variable parts, indicated like this: <name> where name is some name. You can also use integers, for that use <int:name>.

Parameters:
add_error_handler(code, controller)

Associates a ControllerFactory with an HTTP error code

Parameters:

New in version 0.0.7.

run()

Run the server, and block the current thread.