All Projects → useflyyer → flyyer-python

useflyyer / flyyer-python

Licence: other
Python helpers to create https://flyyer.io URLs for link previews | Manage your og:images from a single dashboard

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to flyyer-python

flyyer-wp
👉 Visit the wiki: https://github.com/useflyyer/flyyer-wp/wiki | Generate social share images with web technologies
Stars: ✭ 13 (+18.18%)
Mutual labels:  open-graph, twitter-cards, image-generator, flyyer
flyyer-ruby
Ruby helpers to create https://cdn.flyyer.io URLs | Og:Image as a Service
Stars: ✭ 13 (+18.18%)
Mutual labels:  open-graph, twitter-cards, image-generator, flyyer
Og Image
Open Graph Image as a Service - generate cards for Twitter, Facebook, Slack, etc
Stars: ✭ 2,706 (+24500%)
Mutual labels:  open-graph, twitter-cards, image-generator
SeoTags
SeoTags create all SEO tags you need such as meta, link, twitter card (twitter:), open graph (og:), and JSON-LD schema (structred data).
Stars: ✭ 113 (+927.27%)
Mutual labels:  open-graph, twitter-cards
furlex
A structured data extraction tool written in Elixir
Stars: ✭ 42 (+281.82%)
Mutual labels:  open-graph, twitter-cards
magento2-module-seo
Magento 2 Module for Search Engine Optimization
Stars: ✭ 100 (+809.09%)
Mutual labels:  twitter-cards
oge
Page metadata as a service
Stars: ✭ 22 (+100%)
Mutual labels:  open-graph
cookiecutter-modern-pypackage
Cookiecutter template for a modern Python package.
Stars: ✭ 97 (+781.82%)
Mutual labels:  poetry
weapp-poem
诗词墨客 - 最全中华古诗词小程序
Stars: ✭ 409 (+3618.18%)
Mutual labels:  poetry
action-python-poetry
Template repo to quickly make a tested and documented GitHub action in Python with Poetry
Stars: ✭ 85 (+672.73%)
Mutual labels:  poetry
ponim
Nim + Python + Poetry = :)
Stars: ✭ 32 (+190.91%)
Mutual labels:  poetry
Divan.hs
Ottoman Divan poetry vezin checker in Haskell!
Stars: ✭ 37 (+236.36%)
Mutual labels:  poetry
poet-v
Vim Meets Poetry and Pipenv Virtual Environments
Stars: ✭ 57 (+418.18%)
Mutual labels:  poetry
blackout
Procedurally generated blackout poetry
Stars: ✭ 56 (+409.09%)
Mutual labels:  poetry
cummings.ee
A collection of the work of Edward Estlin Cummings, as it enters the public domain.
Stars: ✭ 32 (+190.91%)
Mutual labels:  poetry
fish-poetry
🐟🐍 a fish plugin that automatically activates the poetry subshell
Stars: ✭ 25 (+127.27%)
Mutual labels:  poetry
poesy
Poetry generation via natural language markov models
Stars: ✭ 56 (+409.09%)
Mutual labels:  poetry
inboard
🚢 Docker images and utilities to power your Python APIs and help you ship faster. With support for Uvicorn, Gunicorn, Starlette, and FastAPI.
Stars: ✭ 106 (+863.64%)
Mutual labels:  poetry
Saaghar
“Saaghar” (ساغر) is a Persian poetry software written by C++ under Qt framework, it uses "ganjoor" database as its database. It has tab feature in both its “Viewer” and its “Search” page that cause it be suitable for research goals.
Stars: ✭ 42 (+281.82%)
Mutual labels:  poetry
Text-Generate-RNN
中国古诗生成(文本生成)
Stars: ✭ 106 (+863.64%)
Mutual labels:  poetry

flyyer-python

PyPI - Version PyPI - Downloads

The AI-powered preview system built from your website (no effort required).

Flyyer live image

This module is agnostic to any Python framework.

Index

Get started (5 minutes)

Haven't registered your website yet? Go to Flyyer.io and create a project (e.g. website-com).

1. Install the library

This module requires Python >= 3.6.

Install it with Poetry.

poetry add flyyer

Or install it with pip.

pip install flyyer

2. Get your Flyyer.io smart image link

In your website code (e.g. your landing or product/post view file), set the following:

from flyyer import Flyyer

flyyer = Flyyer(
  # Your project slug
  project="website-com",
  # The current path of your website
  path="/path/to/product", # In Django you can use {{ request.get_full_path }}
  # (Optional, Recommended) Default or main image for each page
  default="/static/image-1.png" # or https://your-site.com/static/image-1.png
)

# Check:
print(flyyer.href())
# > https://cdn.flyyer.io/v2/website-com/_/__v=1618281823&_def=%2Fstatic%2Fimage-1.png/path/to/product

3. Put your smart image link in your <head> tags

You'll get the best results like this:

<meta property="og:image" content="{{ flyyer.href() }}">
<meta name="twitter:image" content="{{ flyyer.href() }}">
<meta name="twitter:card" content="summary_large_image">

4. Create a rule for your project

Go to your dashboard here and create a rule like the following:

Flyyer basic rule example

Voilà!

Advanced usage

Advanced features include:

  • Custom variables: additional information for your preview that is not present in your website. [Note: if you need customization you should take a look at Flyyer Render]
  • Custom metadata: set custom width, height, resolution, and more (see example).
  • Signed URLs.

Here you have a detailed full example for project website-com and path /path/to/product.

from flyyer import Flyyer, FlyyerMeta

flyyer = Flyyer(
  # [Required] Your project slug, find it in your dashboard https://www.flyyer.io/dashboard/_/projects/_/integrate.
  project="website-com",
  # [Recommended] The current path of your website (by default it's `/`).
  path="/path/to/product",
  # [Optional] In case you want to provide information that is not present in your page set it here.
  variables={
    "title": "Product name",
    "img": "https://flyyer.io/img/marketplace/flyyer-banner.png",
  },
  # [Optional] Custom metadata for rendering the image. ID is recommended so we provide you with better statistics.
  meta=FlyyerMeta(
    id="jeans-123", # recommended for better stats
    v="12369420123", # specific handler version, by default it's a random number to circumvent platforms' cache,
    width=1200,
    height=600,
    resolution=0.9, # from 0.0 to 1.0
    agent="whatsapp", # force dimensions for specific platform
  ),
)

# Check:
print(flyyer.href())
# > https://cdn.flyyer.io/v2/website-com/_/__v=1618281823/path/to/product

For signed URLs, just provide your secret (find it in Dashboard > Project > Advanced settings) and choose a strategy (HMAC or JWT).

flyyer = Flyyer(
  project="website-com",
  path="/path/to/product",
  secret="your-secret-key",
  strategy="JWT", # or 'HMAC'
)

print(flyyer.href())
# > https://cdn.flyyer.io/v2/website-com/jwt-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJhbXMiOnsiX19pZCI6ImplYW5zLTEyMyJ9LCJwYXRoIjoiXC9wYXRoXC90b1wvcHJvZHVjdCJ9.X8Vs5SGEA1-3M6bH-h24jhQnbwH95V_G0f-gPhTBTzE?__v=1618283086

Flyyer Render

As you probably realized, Flyyer uses the rules defined on your dashboard to decide how to handle every image based on path patterns. It analyses your website to obtain information and then render a content-rich image with no effort. Let's say "Flyyer delivers images based on the content of this route".

Flyyer Render instead requires you to explicitly declare template and variables for the images to render, giving you more control for customization. Let's say "FlyyerRender delivers an image using this template and these explicit variables".

from flyyer import FlyyerRender

flyyer = FlyyerRender(
    tenant="tenant",
    deck="deck",
    template="template",
    variables={"title": "Hello world!"},
)

# Use this image in your <head/> tags
url = flyyer.href()
# > https://cdn.flyyer.io/render/v2/tenant/deck/template.jpeg?__v=1596906866&title=Hello+world%21

Variables can be complex arrays and hashes.

from flyyer import FlyyerRender, FlyyerMeta

flyyer = FlyyerRender(
    tenant="tenant",
    deck="deck",
    template="template",
    variables={
        "items": [
            { "text": "Oranges", "count": 12 },
            { "text": "Apples", "count": 14 },
        ],
    },
    meta=FlyyerMeta(
        id="slug-or-id", # To identify the resource in our analytics report
    ),
)

You can use signatures with Flyyer Render like below.

from flyyer import FlyyerRender

flyyer = FlyyerRender(
    tenant="tenant",
    deck="deck",
    template="template",
    variables={"title": "Hello world!"},
    secret=key,
    strategy="HMAC", # JWT
)

# Use this image in your <head/> tags
url = flyyer.href()
# > https://cdn.flyyer.io/render/v2/tenant/deck/template.jpeg?__v=d+&title=Hello+world%21&__hmac=1bea6d523496848c

IMPORTANT: variables must be serializable.

To decode the URL for debugging purposes:

from urllib.parse import unquote

print(unquote(url))
# > https://cdn.flyyer.io/render/v2/tenant/deck/template.jpeg?title=Hello+world!&__v=123

Development

Prepare the local environment:

poetry install
poetry shell

Deploy with:

# Set API Token
poetry config pypi-token.pypi pypi-TOKEN

poetry version X.Y.Z
poetry build
poetry publish

Test

Run tests with pytest:

poetry run pytest

Run black linter:

black .
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].