-1

I am new to the flask. I have a problem. I want to use a symptoms parameter from select_symptoms function to get_match function. thank you :)

this my code

@app.route('/organ/id/symptoms/<int:symptoms>', methods=["GET"])
def select_sysmptoms(symptoms):
    cur = mysql.connect().cursor()
    cur.execute('select symptoms, id, from symptoms where id in (' + str(symptoms) + ')')
    symptoms = [dict((cur.description[i][0], value)
              for i, value in enumerate(row)) for row in cur.fetchall()]
    return jsonify({'The Symptoms': symptoms})

#Diagnosis the symptoms
@app.route('/organ/id/symptoms/diagnosis/')
def get_match():
    #how to use the symptoms parameter in select_symptoms function ?/
    new_symptoms = request.parameter_storage_class(symptoms)
    return jsonify(new_symptoms)

1 Answers1

2

define a global variable:

a = []
@app.route('/organ/id/`enter code here`symptoms/<int:symptoms>', methods=["GET"])
def select_sysmptoms(symptoms):
    cur = mysql.c`enter code here`onnect().cursor()
    cur.execute('select symptoms, id, from symptoms where id in (' + str(symptoms) + ')')
    symptoms = [dict((cur.description[i][0], value)
              for i, value in enumerate(row)) for row in cur.fetchall()]
    global a
    a = symptoms
    return jsonify({'The Symptoms': symptoms})

#Diagnosis the symptoms
@app.route('/organ/id/symptoms/diagnosis/')
def get_match():
    symptoms = a
    new_symptoms = request.parameter_storage_class(symptoms)
    return jsonify(new_symptoms)
Divyessh
  • 2,540
  • 1
  • 7
  • 24