Created
June 18, 2017 18:08
-
-
Save ju5t/924e9ea87c4313e82bfdea930991762b to your computer and use it in GitHub Desktop.
A sample Flask application used with Enchant Customer Support Software
This file contains hidden or 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
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