sprockets.handlers.heartbeat/docs/examples.rst

25 lines
586 B
ReStructuredText
Raw Normal View History

2014-10-13 15:16:28 +00:00
Examples
========
The following example demonstrates how to create a method that is invoked on
each call to ``/heartbeat`` in a web application.
2014-10-13 15:16:28 +00:00
.. code:: python
from sprockets.handlers import heartbeat
from tornado import web
2014-10-13 15:16:28 +00:00
def check_database():
"""Any check method should return a bool specifying the check is ok.
:rtype: bool
"""
return True
# Register the check method
heartbeat.register_callback(check_database)
# Create a Tornado application
app = web.Application([('/heartbeat', heartbeat.HeartbeatHandler)])