Automatically generate data APIs for your Flask routes
Project description
Automatically generate data APIs for your Flask routes, with very little effort on your part. It should integrate into your existing application with very few changes required.
Usage
Given the following code:
from flask import Flask app = Flask(__name__) @app.route('/foo') def foo(): return render_template('foo.html', foo='bar', baz='boo')
We can automatically generate API functions for this route, rather simply:
from flask import Flask from flask_dataapi import DataApi app = Flask(__name__) api = DataApi(app) @api.route('/foo') def foo(render_template): return render_template('foo.html', foo='bar', baz='boo')
There are only two changes made. First, we call api.route for the decorator, and second, the first argument to the view function is the render_template function that we’ll call.
This will automatically add a second route of /foo.json that outputs JSON of the data that was provided to render_template. The route will have a name of foo_api, so links or other references will use that name, e.g. url_for('foo_api').
Motivation
In addition to free code, we also need free data. This makes it trivial to ensure that all data presented to users is easily extractable by the user.
License
flask-dataapi is available under the terms of the AGPL, version 3 or any later version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask_dataapi-0.2.1.tar.gz
.
File metadata
- Download URL: flask_dataapi-0.2.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e20cf7237854d9a90d7decef2360a66c713e4545773ea5166a67a6309a2001e3 |
|
MD5 | e723c495c01a7e3e34f939af4896e743 |
|
BLAKE2b-256 | 77f34e174d485d84ac232e90155ba6f45e89d90c1e7d7370a088f4d90cb82ca5 |
File details
Details for the file flask_dataapi-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: flask_dataapi-0.2.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed9181ea90556e5282db2a53c9b7a2832c8b30ccd0c9f3fba2fa82237b6b1526 |
|
MD5 | 3057682c71f0ab6b9cf5ea0e03fcd183 |
|
BLAKE2b-256 | fc7f9a2ced425acad41af242ab9b9a202997125843a15b10c934948d49b2fc2b |