-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
27 lines (20 loc) · 887 Bytes
/
Copy pathapp.py
File metadata and controls
27 lines (20 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from flask import Flask, request, jsonify
from flask_cors import CORS, cross_origin
app = Flask(__name__)
app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog'
app.config['CORS_HEADERS'] = 'Content-Type'
cors = CORS(app, resources={r"/api/button-click": {"origins": "http://localhost:5002"}})
@app.route('/api/button-click', methods=['POST'])
@cross_origin(origin='localhost',headers=['Content- Type','Authorization'])
def handle_button_click():
data = request.get_json()
button_type = data.get('buttonType')
if button_type == 'primary':
response = "You clicked on the Primary Button"
elif button_type == 'secondary':
response = "You clicked on the Secondary Button"
else:
response = "Invalid button type"
return jsonify({"response": response})
if __name__ == '__main__':
app.run(host='localhost', port=5002)