Web Application

import vodka.app
import vodka.config

@vodka.app.register('my_app')
class MyApp(vodka.app.WebApplication):

    def index(self):
        return self.render("index.html", self.wsgi_plugin.request_env())

    def view(self, id):
        return self.render("view.html", self.wsgi_plugin.request_env())

    def create(self):
        # flask request object
        req = self.wsgi_plugin.request_env().get("request")

WSGI Frameworks

Flask

Currently the only supported wsgi framework is flask, although we hope to extend this soon.

Install requirements

pip install flask

Plugin configuration

plugins:
- name: http
  type: flask

  # server website to host and port
  host: 0.0.0.0
  port: 7041

  # flask debug logging on or off
  debug: true
  # specify which wsgi server to use
  server: gevent
  # specify which way you want to handle running the server async
  async: gevent

  routes:
    # route url path '/' to application 'my_app', method 'index'
    /: my_app->index
    # route url path '/view/<id>' to application 'my_app', method 'view' with argument 'id'
    /view/<id>: my_app->view
    # allow post method to '/create'
    /create:
      methods:
        - POST
      target: my_app->create

WSGI Servers

Can be specified by setting the 'server' config attribute in your wsgi framework config (eg. flask plugin config)

Gevent

  • config value: 'gevent'

Install requirements

pip install gevent

Run

bartender serve --config=/path/to/vodka/home

Gunicorn

  • config value: 'gunicorn'

Install requirements

pip install gunicorn

Run

export VODKA_HOME=/path/to/vodka/home
gunicorn -b 0.0.0.0:7026 vodka.runners.wsgi:application

UWSGI

  • config value: 'uwsgi'

Install requirements

pip install uwsgi

Run

export VODKA_HOME=/path/to/vodka/home
uwsgi -H $VIRTUAL_ENV --socket=0.0.0.0:7026 -w vodka.runners.wsgi:application --enable-threads