{"id":17236602,"url":"https://github.com/illright/flask-pywebpush","last_synced_at":"2025-04-14T02:26:18.948Z","repository":{"id":57430619,"uuid":"251441073","full_name":"illright/flask-pywebpush","owner":"illright","description":"A clean interface to pywebpush from Flask","archived":false,"fork":false,"pushed_at":"2020-12-09T09:17:07.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-16T06:16:27.332Z","etag":null,"topics":["flask","webpush"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/Flask-pyWebPush/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/illright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-30T22:17:42.000Z","updated_at":"2024-10-10T16:37:13.000Z","dependencies_parsed_at":"2022-08-27T22:11:51.478Z","dependency_job_id":null,"html_url":"https://github.com/illright/flask-pywebpush","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illright%2Fflask-pywebpush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illright%2Fflask-pywebpush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illright%2Fflask-pywebpush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illright%2Fflask-pywebpush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/illright","download_url":"https://codeload.github.com/illright/flask-pywebpush/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240142740,"owners_count":19754633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","webpush"],"created_at":"2024-10-15T05:36:32.781Z","updated_at":"2025-02-24T14:31:30.987Z","avatar_url":"https://github.com/illright.png","language":"Python","readme":"# Flask-pyWebPush\n\n[![PyPI version shields.io](https://img.shields.io/pypi/v/flask-pywebpush.svg)](https://pypi.python.org/pypi/flask-pywebpush/)\n\nA clean interface to `pywebpush` from Flask. Basically, a very thin wrapper.\n\n## Installation\n\nThe package is available [at the PyPI](https://pypi.org/project/Flask-pyWebPush/):\n\n```bash\n$ pip install flask-pywebpush\n```\n\n## Quickstart\n\n### Instantiation\n\nInstantiate this extension like any other Flask extension:\n\n```python\nfrom flask_pywebpush import WebPush\napp = Flask()\npush = WebPush(app)\n```\n\nOr you may initialize the extension with the Flask instance later:\n\n```python\nfrom flask_pywebpush import WebPush\napp = Flask()\npush = WebPush()\npush.init_app(app)\n```\n\n\n### VAPID keys and sender info\n\nWebPush sender requires a private key and an identification URL to operate. For more information on those values, see [this article on Google Developers](https://developers.google.com/web/fundamentals/push-notifications/subscribing-a-user#how_to_create_application_server_keys).\n\nYou may specify these values to the extension by setting the following configuration variables of the Flask instance:\n\n* `WEBPUSH_VAPID_PRIVATE_KEY`\n  The application server private key. As with `pywebpush`, it may either be the literal key value (DER representation) or a path to a VAPID EC2 private key PEM file;\n* `WEBPUSH_SENDER_INFO`: a URL containing information to contact the notification sender. Commonly a mailto: URL.\n\nAlternatively, you can pass these values on creation of the `WebPush` extension instance or to the `init_app` method later on:\n\n```python\nfrom flask_pywebpush import WebPush\npush = WebPush(private_key='some_value',\n               sender_info='mailto:admin@server.com')\n```\n\n### Notification sending\n\nAssuming you've got the subscription storage done, you may send a notification to a given subscription object like so:\n\n```python\nfrom flask_pywebpush import WebPushException\n\nsubscription = {\n    'endpoint': '---some-value---',\n    'keys': { ... }\n}\nnotification = {\n    'title': 'Test',\n    'body': 'notification body',\n}\n\ntry:\n    push.send(subscription, notification)\nexcept WebPushException as exc:\n    print(exc)\n```\n\nYou can also pass keyword arguments like `verbose=True` to `.send()`, which will be directly passed to `pywebpush.webpush()`\n\n\n## Extended Usage\n\nSince this is a wrapper over `pywebpush`, it exposes the main objects of the underlying library, namely, `webpush`, `WebPushException`, `WebPusher`.  \nAll of them may be directly imported from `flask_pywebpush`.\n\nThe `WebPush` extension instance also has a `get_webpusher(subscription)` method, allowing you to get a `pywebpush.WebPusher` instance for a given subscription.\n\nIf your usage requires more VAPID claims than simply `{\"sub\": \"sender_info\"}`, then you may override the passed claims using the `set_claims` method:\n\n```python\nfrom flask_pywebpush import WebPush\npush = WebPush()\npush.set_claims({})  # whatever VAPID claims you might need\n```\n\n## License\n\n[MIT](https://github.com/illright/flask-webpush/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fillright%2Fflask-pywebpush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fillright%2Fflask-pywebpush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fillright%2Fflask-pywebpush/lists"}