Skip to content
Pierre Quentel edited this page Apr 24, 2016 · 1 revision

Server options

The built-in server is started with the function

Karrigell.run(_handler,port,apps,server,address_family_)

  • handler is the class that manages requests (defaults to Karrigell.RequestHandler)
  • port defaults to 80
  • apps is the list of supported applications (defaults to [Karrigell.App])
  • server defaults to socketserver.ThreadingTCPServer from the Python standard distribution
  • address_family defaults to socket.AF_INET (IPv4) but can be set to socket.AF_INET6 to support IPv6

SSL mode

The built-in server can be configured in SSL mode

For this, you must generate a key and certificate file (a file with the extension .pem). You can use OpenSSL for that : the instructions on how to generate such a file are explained in detail on the OpenSSL site.

(Warning : on Windows, once the openssl.exe is installed, you are likely to have a message saying that the configuration file openssl.cnf is not found. You can fix this by adding -config /path/to/openssl/bin/openssl.cfg at the end of the request to create the file)

The module sslserver provides the class SSLServer. Its class attribute pem must be set to the path of the .pem file. This class is passed to the run() method of Karrigell.

import Karrigell
import Karrigell.sslserver

# start the SSL web server on port 443 to serve this application
server = Karrigell.sslserver.SSLServer
server.pem = "server.pem" # replace with correct path
Karrigell.run(server=server,port=443)

This will serve requests like https://localhost/script on port 443.

GettingStarted

Clone this wiki locally