FLAYYER.com helper classes and methods
Project description
flayyer-python
This module is agnostic to any Python framework and has zero external dependencies.
To create a FLAYYER template please refer to: flayyer.com
This module requires Python >=3.6
Installation
Install it with Poetry, the modern package manager.
poetry add flayyer
Don’t worry: if poetry is not your thing, you can also use pip.
pip install flayyer
Note: This client requires Python 3.6+.
Usage
After installing the package you can format URL as:
from flayyer import Flayyer
flayyer = Flayyer(
tenant="tenant",
deck="deck",
template="template",
variables={"title": "Hello world!"},
)
# Use this image in your <head/> tags
url = flayyer.href()
# > https://flayyer.io/v2/tenant/deck/template.jpeg?__v=1596906866&title=Hello+world%21
Variables can be complex arrays and hashes.
from flayyer import Flayyer, FlayyerMeta
flayyer = Flayyer(
tenant="tenant",
deck="deck",
template="template",
variables={
"items": [
{ "text": "Oranges", "count": 12 },
{ "text": "Apples", "count": 14 },
],
},
meta=FlayyerMeta(
id="slug-or-id", # To identify the resource in our analytics report
),
)
IMPORTANT: variables must be serializable.
To decode the URL for debugging purposes:
from urllib.parse import unquote
print(unquote(url))
# > https://flayyer.io/v2/tenant/deck/template.jpeg?title=Hello+world!&__v=123
Development
Prepare the local environment:
poetry install
poetry shell
Run tests with pytest:
pytest
Run black linter:
black .
Deploy with:
# Set API Token
poetry config pypi-token.pypi pypi-TOKEN
poetry version X.Y.Z
poetry build
poetry publish
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/flayyer/flayyer-python.
License
The module is available as open source under the terms of the MIT License.
Acknowledgements
Heads up to @nebil for his advice in the development of this Python module.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.