@app.route("/api/user_projects/<student_email>", methods=["GET"])
def get_projects_names_by_student_email(student_email):
a = cabinet_client.get_projects_names_by_student_email(student_email)
return json.dumps(a)
@app.route("/api/user_projects/<student_email>", methods=["GET", "POST"])
def get_projects_names_by_student_email(student_email):
a = cabinet_client.get_projects_names_by_student_email(student_email)
return json.dumps(a)
import requests
respounse = requests.post('домен/api/user_projects/{почта}').json()
print(respounse)
@app.route("/api/user_projects/<student_email>", methods=["GET", "POST"])
def get_projects_names_by_student_email(student_email):
a = cabinet_client.get_projects_names_by_student_email(student_email)
return a
return a сделай json.damps
A common response format when writing an API is JSON. It’s easy to get started writing such an API with Flask. If you return a dict or list from a view, it will be converted to a JSON response.
Распространенным форматом ответа при написании API является JSON. Начать писать такой API с помощью Flask легко. Если вы вернете из представления dict или list, оно будет преобразовано в ответ JSON.
from flask import jsonify
@app.route("/api/user_projects/<student_email>", methods=["GET", "POST"])
def get_projects_names_by_student_email(student_email):
a = cabinet_client.get_projects_names_by_student_email(student_email)
return jsonify(a)