Created
February 20, 2020 12:46
-
-
Save SuryaSankar/8c8ea67978f91953673b0d19be24e073 to your computer and use it in GitHub Desktop.
Simple api for push subscriptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/api/push-subscriptions", methods=["POST"]) | |
def create_push_subscription(): | |
json_data = request.get_json() | |
subscription = PushSubscription.query.filter_by( | |
subscription_json=json_data['subscription_json'] | |
).first() | |
if subscription is None: | |
subscription = PushSubscription( | |
subscription_json=json_data['subscription_json'] | |
) | |
db.session.add(subscription) | |
db.session.commit() | |
return jsonify({ | |
"status": "success" | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment