Skip to main content

A Flask extension to add support for the OpenHeart protocol

Project description

Flask-OpenHeart

Flask-OpenHeart adds OpenHeart support to Flask applications, providing a simple way for users to react with emojis to Flask URLs.

Flask-OpenHeart can be installed from PyPI:

pip install flask-openheart

And initialized like a typical Flask extension:

from flask import Flask
from flask_openheart import OpenHeart

app = Flask(__name__)
openheart = OpenHeart()
openheart.init_app(app)

To enable OpenHeart support for an endpoint, simply add openheart=True:

@app.route("/foo/", openheart=True)
def foo(self):
    return "<p>hello, world</p>"

This creates a "/foo/" endpoint as normal. This also creates a "/openheart/foo/" endpoint.

Users can react to "/foo/" by submitting a POST request to "/openheart/foo/" containing any emoji. For example:

curl -d '❤️' -X POST 'http://localhost:5000/openheart/foo/'

Users can query the current reactions by submitting a GET request to "/openheart/foo/". For example:

curl 'http://localhost:5000/openheart/foo/'

You can also easily add information about reactions into your endpoint:

@app.route("/foo/", openheart=True)
def foo(self):
    hearts_count = flask.request.openheart.reactions["❤️"]
    return "<p>Number of ❤️ reactions: {hearts_count}</p>"

Full documentation for Flask-OpenHeart is available at ReadTheDocs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_openheart-0.0.1.tar.gz (126.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_openheart-0.0.1-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file flask_openheart-0.0.1.tar.gz.

File metadata

  • Download URL: flask_openheart-0.0.1.tar.gz
  • Upload date:
  • Size: 126.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for flask_openheart-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9858f10078533477cd6bf50deb8aa42b52e93b2931e7906ba324df282623f539
MD5 6bb556f9a059b7600c6dc476f1f357dc
BLAKE2b-256 a79d318848aaae5aad22e0ea4657ef6292b067a797762c56f31dd947c1c07831

See more details on using hashes here.

File details

Details for the file flask_openheart-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_openheart-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 621dfe0cf658f2f87709c4e08d48c3820328ce986f89c4cef35b46d284b7514d
MD5 41fe29a33e5a17ed10c9ee7c9121f1f8
BLAKE2b-256 a235e6d4385f0f1a5d556438eda5154b57df7e1d0d8e7165b0c0810291de7941

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page