@app.route("<STR_LIT>", methods=["<STR_LIT:GET>", "<STR_LIT:POST>"])<EOL>def webhook():
<EOL>if request.method == "<STR_LIT:GET>" and "<STR_LIT>" in request.args:<EOL><INDENT>print("<STR_LIT>")<EOL>return request.args["<STR_LIT>"]<EOL><DEDENT>is_genuine = verify_signature(<EOL>message=request.data,<EOL>key=app.config["<STR_LIT>"].encode("<STR_LIT:utf8>"),<EOL>signature=request.headers.get("<STR_LIT>"),<EOL>)<EOL>if not is_genuine:<EOL><INDENT>return "<STR_LIT>", <NUM_LIT><EOL><DEDENT>data = request.get_json()<EOL>for delta in data["<STR_LIT>"]:<EOL><INDENT>process_delta.delay(delta)<EOL><DEDENT>return "<STR_LIT>", <NUM_LIT:200><EOL>
When the Flask server gets a request at the `/webhook` URL, it will run
this function. Most of the time, that request will be a genuine webhook
notification from Nylas. However, it's possible that the request could
be a fake notification from someone else, trying to fool our app. This
function needs to verify that the webhook is genuine!