@app.route("/data/<dataType>", methods=['GET'])
def realtime(dataType):
_data = None
with open(os.path.join("data/"+ dataType +".json")) as f:
_data = json.loads(f)
return dumps(_data)
I wrote this code to get data in JSON format from a file, but it keeps giving me the error:
TypeError: expected string or buffer
What is wrong with it?
loadsexpects a string with json, not a file object. Useloadinstead