Flask/Rest Get a string from another web service

2019-08-27 19:08发布

问题:

I have two web services called getCourseCodeWS and checkStudentOnCourseWS both with 1 corresponding DB. The first WS returns a courseCode from a DB. This courseCode should work as a parameter in my checkStudentOnCourseWS which should use the courseCode + another parameter called personalIdentityNumber, which I get from checkStudentOnCourseWS's DB. This should return a true/false depending on if the arguments match the database, in other words, if the student appears in the course.

My question is how do I request the actual respons I get from my getCourseCodeWS to work as an argument for checkStudentOnCourseWS?

@app.route('/courses/<course>/<period>', methods= ["GET"])
def checkCourseCodeWS(course, period):
myCursor2 = mydb.cursor()

query2 = ("SELECT courseCode FROM paraplyet.courseInfo WHERE courseName = " + "'" + course + "' AND duration = " + "'" + period + "'")
myCursor2.execute(query2)
myresult2 = myCursor2.fetchall()

return jsonify(myresult2)