v. 1.22.0


To run apps built with the Bottle web framework using Unit:

  1. Install Unit with a Python 2.7+ language module.

  2. Create a virtual environment to install Bottle’s PIP package, for instance:

    $ cd /path/to/app/
    $ python --version
          Python x.y.z
    $ python -m venv venv
    $ source venv/bin/activate
    $ pip install bottle
    $ deactivate


    Create your virtual environment with a Python version that matches the language module from Step 1 up to the minor number (x.y in this example). Also, the app type in Step 5 must resolve to a similarly matching version; Unit doesn’t infer it from the environment.

  3. Let’s try an updated version of the quickstart app, saving it as /path/to/app/

    from bottle import Bottle, template
    app = Bottle()
    def hello(name):
        return template('Hello, {{name}}!', name=name)
    # run(app, host='localhost', port=8080)

    Note that we’ve dropped the server code.

  4. Run the following command for each directory containing app code or data so Unit can access it:

    # chown -R unit:unit /path/to/app/


    The unit:unit user-group pair is available only with official packages, Docker images, and some third-party repos. Otherwise, account names may differ; run the ps aux | grep unitd command to be sure.

    For further details, including permissions, see the security checklist.

  5. Next, prepare the Bottle configuration for Unit:

        "listeners": {
            "*:80": {
                "pass": "applications/bottle"
        "applications": {
            "bottle": {
                "type": "python x.y",
                "path": "/path/to/app/",
                "home": "/path/to/app/venv/",
                "module": "wsgi",
                "callable": "app"
  6. Upload the updated configuration. Assuming the JSON above was added to config.json:

    # curl -X PUT --data-binary @config.json --unix-socket \
           /path/to/control.unit.sock http://localhost/config/


    The control socket path may vary; run unitd --help or see Startup and Shutdown for details.

    After a successful update, your app should be available on the listener’s IP address and port:

    $ curl http://localhost/hello/Unit
          Hello, Unit!