Flask extension to help register functions to run at the end of the current request.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Brett Langdon 8ebe30d38d
Fix travis build
10 years ago
.gitignore Initial version of module 10 years ago
.travis.yml Fix travis build 10 years ago
CHANGELOG Initial version of module 10 years ago
LICENSE Initial version of module 10 years ago
MANIFEST.in Initial version of module 10 years ago
README.rst Initial version of module 10 years ago
example.py Initial version of module 10 years ago
flask_defer.py Initial version of module 10 years ago
setup.py Initial version of module 10 years ago
test_flask_defer.py Initial version of module 10 years ago

README.rst

Flask-Defer
=========

.. image:: https://badge.fury.io/py/flask-defer.svg
:target: https://badge.fury.io/py/flask-defer
.. image:: https://travis-ci.org/brettlangdon/flask-defer.svg?branch=master
:target: https://travis-ci.org/brettlangdon/flask-defer

Easily register a function to execute at the end of the current request.

Installation
~~~~~~~~~~~~

.. code:: bash

pip install Flask-Defer


Usage
~~~~~

.. code:: python

from flask import Flask
from flask_defer import FlaskDefer, after_request

app = Flask(__name__)
FlaskDefer(app)


def defer_me(name, say_hello=False):
if say_hello:
print 'Saying hello to, {name}'.format(name=name)


@app.route('/')
def index():
print 'Start of request method'

# Defer `defer_me` until after the current request has finished
after_request(defer_me, 'name', say_hello=True)

print 'Ending request method'

return 'Thanks!'


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


.. code:: bash

$ python example.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Start of request method
Ending request method
Saying hello to, name
127.0.0.1 - - [28/Nov/2016 15:41:39] "GET / HTTP/1.1" 200 -