Skip to content

Instantly share code, notes, and snippets.

@ju5t
Created June 18, 2017 18:08
Show Gist options
  • Save ju5t/924e9ea87c4313e82bfdea930991762b to your computer and use it in GitHub Desktop.
Save ju5t/924e9ea87c4313e82bfdea930991762b to your computer and use it in GitHub Desktop.
A sample Flask application used with Enchant Customer Support Software
import hmac
import hashlib
import json
from flask import Flask, request
app = Flask(__name__)
# Get the security from your sidebar app settings
security_key = 'My-Enchant-Signature'
@app.route('/', methods=['POST'])
def customer_data():
payload = json.loads(request.data)
enchant_signature = request.headers.get('Enchant-Signature')
verify_signature = hmac.new(security_key, request.data, hashlib.sha256).hexdigest()
if enchant_signature != verify_signature:
return 'Error'
return 'Sidebar app'
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment