diff --git a/docs/source/flask.rst b/docs/source/flask.rst new file mode 100644 index 0000000..a932200 --- /dev/null +++ b/docs/source/flask.rst @@ -0,0 +1,38 @@ +.. _flasking: + +************** +Use with Flask +************** + +A `flask`_ extension is also provided so it's easy to get started with +developing new web interfaces with calibrestekje. In order to get started +you'll need to install the extension. + +.. _flask: https://flask.palletsprojects.com + +.. code-block:: bash + + $ pip install flask-calibrestekje + +And then go ahead and create a ``flaskconfig.cfg`` file. + +.. code-block:: config + + CALIBRESTEKJE_SQLITE_URL = "sqlite:///mymetadata.db" + +And then finally, create your Flask application. + +.. code-block:: python + + from calibrestekje import Book + from flask import Flask, jsonify + + from flask_calibrestekje import CalibreStekje + + app = Flask(__name__) + app.config.from_pyfile("config.cfg") + db = CalibreStekje(app) + + @app.route("/") + def home(): + return jsonify({"book-count": db.session.query(Book).count()}) diff --git a/docs/source/index.rst b/docs/source/index.rst index dc9323c..ab6c009 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -9,6 +9,7 @@ examples modules-api forking + flask upgrade contribute changelog