Flask-Pushrod is a simple helper for Flask for doing content negotiation (primarily for running the API and the website on the same code-base, with as little separate handling as possible).
Installation
Flask-Pushrod is available on PyPI, so to install the latest stable version simply run
pip install Flask-Pushrod
or
easy_install Flask-Pushrod
Usage
A simple hello world app in Pushrod would look like this:
from flask import Flask, render_template
from flask.ext.pushrod import Pushrod, pushrod_view
import random
app = Flask(__name__)
Pushrod(app)
@app.route("/")
@pushrod_view(jinja_template="hello.html")
def hello():
return {
'greeting': random.choice(("Hi", "Heya"))
}
if __name__ == "__main__":
app.run()
This would, depending on the request, return either the greeting message in JSON or render it through the Jinja2 hello.html template.
Tests
$ tox
Documentation
More advanced documentation is available on Read The Docs.
Release files for Flask-Pushrod 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Flask-Pushrod-0.3.tar.gz | 9.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Flask_Pushrod-0.3-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 22.5 kB
Release files / Flask-Pushrod-0.3.tar.gz
| Download URL | Flask-Pushrod-0.3.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7174a51da3b1d0af4dca0360b3917f1a33ab79508a2897b37a42f94f51d038b2
|
|
BLAKE2b-256 checksum How to use checksums |
cf17febcd0e774dd5c50c5db14b5db78a942ed1ba6a122c394292cb32e4f090b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Flask_Pushrod-0.3-py2-none-any.whl
| Download URL | Flask_Pushrod-0.3-py2-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
dcce96108e4b17d029646e7bc75e95c766a1ae80e4d9f1a30a34613cfffbbef7
|
|
BLAKE2b-256 checksum How to use checksums |
a3bbf8c36f12314ac63c360d85e9628e7de5fd79bf2f216a2692a7c91fcd2fd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |