Skip to main content

Flask module for the Coralillo redis ORM

Project description

Integrates the Coralillo Redis ORM into flask

Usage

This is an easy application that stores and retrieves cars from redis database.

# app.py
from flask import Flask, request, redirect
from flask_coralillo import Coralillo
from coralillo import Model, fields

app = Flask(__name__)

engine = Coralillo(app)

class Car(Model):
    name = fields.Text()

    class Meta:
        engine = engine

@app.route('/')
def list_cars():
    res = '<h1>Cars</h1><ul>'

    for car in Car.get_all():
        res += '<li>{}</li>'.format(car.name)

    res += '</ul><h3>Add car</h3>' + \
        '<form method="POST">' + \
        '<input name="name">' + \
        '<input type="submit" value="Add">' + \
        '</form>'

    return res

@app.route('/', methods=['POST'])
def add_car():
    newcar = Car.validate(**request.form.to_dict()).save()

    return redirect('/')

if __name__ == '__main__':
    app.run()

Now if you run python app.py and you visit http://localhost:5000 you will be able to intercact with your brand new Flask-Coralillo application.

For more information visit https://getfleety.github.io/coralillo/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
Flask_Coralillo-0.1.3-py3-none-any.whl (4.2 kB) Copy SHA256 hash SHA256 Wheel py3 Mar 7, 2018
Flask-Coralillo-0.1.3.tar.gz (2.6 kB) Copy SHA256 hash SHA256 Source None Mar 7, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page