Add flask docs

This commit is contained in:
Luke Murphy 2020-03-01 02:02:14 +00:00
parent 972e9c67c5
commit ec497661e8
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 39 additions and 0 deletions

38
docs/source/flask.rst Normal file
View File

@ -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()})

View File

@ -9,6 +9,7 @@
examples
modules-api
forking
flask
upgrade
contribute
changelog