Flask Integration


This guide simply points out the differences between standalone Relé and the Flask integration. The basics about publishing and consuming are described in the First Steps section.


To configure Relé, our settings may look something like:

RELE = {
    'GC_CREDENTIALS_PATH': 'photo_project/settings/dummy-credentials.json',
    'APP_NAME': 'photo-imaging',

# Later when we setup rele and flask:
app = Flask()
rele.config.setup(RELE, flask_app=app)

The only major difference here is that we are using the rele.contrib.FlaskMiddleware and that we pass the Flask app instance to rele.config.setup method.


Now that that the middleware is setup our subscriptions will automatically have Flask’s app context pushed when they are invoked so you will have access to the database connection pool and all other app dependent utilities.

from models import File
from database import db

def handle_upload(data, **kwargs):
    new_file = File(data)