Skip to content

Instantly share code, notes, and snippets.

@mbeale
Last active December 25, 2015 15:29
Show Gist options
  • Save mbeale/6998412 to your computer and use it in GitHub Desktop.
Save mbeale/6998412 to your computer and use it in GitHub Desktop.
Flask and Easypost handle webhooks
from flask import Flask, request
import easypost
import json
app = Flask(__name__)
@app.route("/webhooks", methods=['POST'])
def webhook():
e = easypost.Event()
e.receive(json.loads(request.form.keys()[0]))
if e.description == 'batch.updated':
#do some processing here
logging.info(e.description)
return 'success'
if __name__ == "__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment