I'm trying to set up a webhook for slack . There i need to return "challenge" attribute value to the request below. I don't know what to write in "response = make_response((),200)" to response correctly.
{
"token": "Jhj5dZrVaK7ZwHHjRyZWjbDl",
"challenge": "3eZbrw1aBm2rZgRNFdxV2595E9CY3gmdALWMmHkvFXO7tYXAYM8P",
"type": "url_verification"
}
import os
from flask import Flask
from flask import request
from flask import make_response
app = Flask(__name__)
@app.route('/webhook2')
def hello_slack():
request_json = request.get_json(silent=True, force=True)
response_body = json.dumps(request_json)
response = make_response((),200)
response.headers['Content-Type'] = 'text/plain'
return response
if __name__ == '__main__':
port = int(os.getenv('PORT', 5000))
app.run(debug=False, port=port, host='0.0.0.0')
Hi I see you have a dict just sitting there at the top of the file; that seems odd. I would guess you want to have some variable equal that dict and response should use variable[“challenge”]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.