Add flask-cors library

This commit is contained in:
Mateusz Szpyruk 2024-03-09 18:28:39 +01:00
parent 69a095fdaf
commit 9f9c5e453f

View File

@ -1,13 +1,15 @@
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
from flask_cors import CORS
app = Flask(__name__) app = Flask(__name__)
CORS(app)
@app.route("/", methods=['GET']) @app.route("/", methods=['GET'])
def recommended_mediators(): def recommended_mediators():
data = request.get_json() data = request.get_json()
request_type = data.get('request_data', {}) input = data.get('request_data', {})
print(request_type) # print(input.get("location"))
top_5 = { top_5 = {
"response_type": "recommended_mediators", "response_type": "recommended_mediators",
@ -17,21 +19,21 @@ def recommended_mediators():
}, [{ }, [{
"name": "Mateusz Szpyruk", "name": "Mateusz Szpyruk",
"specialization": "Prawo podatkowe", "specialization": "Prawo podatkowe",
"location": "Katowice", "location": input.get("location"),
"ai_rating": 99, "ai_rating": 99,
"user_rating": 99, "user_rating": 99,
"number_of_opinions": 5 "number_of_opinions": 5
}, { }, {
"name": "Jan Kowalski", "name": "Jan Kowalski",
"specialization": "Prawo pracy", "specialization": "Prawo pracy",
"location": "Katowice", "location": input.get("location"),
"ai_rating": 90, "ai_rating": 90,
"user_rating": 99, "user_rating": 99,
"number_of_opinions": 5 "number_of_opinions": 5
}, { }, {
"name": "Jan Kowalski", "name": "Jan Kowalski",
"specialization": "Prawo pracy", "specialization": "Prawo pracy",
"location": "Katowice", "location": input.get("location"),
"ai_rating": 90, "ai_rating": 90,
"user_rating": 99, "user_rating": 99,
"number_of_opinions": 5 "number_of_opinions": 5