I am trying to append all my response in an queue under one end point and on other hand im trying to get only one result using another endpoint. But while using second endpoint I get failed as response. what would be the better approach ? Thanks in advance
import requests
import json
import queue
q_sample = queue.Queue()
@app.route('/try',methods=['GET'])
def getschedule():
x = requests.get("https://api.postalpincode.in/pincode/620012",verify=False)
j_data = json.loads(x.content)
for n in j_data:
y = n['PostOffice']
for x in y:
q_sample.put(x)
return jsonify({"size":q_sample.qsize()})
@app.route('/oneschedule',methods=['GET'])
def oneschedule():
if not q_sample.empty():
return jsonify({"schedule":q_sample.get(False)})
else:
return "Failed"