Hello, I am making a web server with Flask
@app.route('/licanse/minus/<licanse_c>')
def minus(licanse_c):
licanse_find = list(db.user.find({"licanse": licanse_c}, {'_id': False}))
if licanse_find == []:
return {"minus": "Licanse does not exist"}
else:
print(licanse_find)
conversion = json.dumps(licanse_find)
licanse_json = json.loads(conversion)
org_sms_stock = licanse_json["sms"]
sms_stock = licanse_json["sms"]
sms_stock = int(sms_stock)
sms_stock = sms_stock-1
org = { "sms": f"{org_sms_stock}" }
new = { "$set": { "sms": f"{sms_stock}" } }
db.update_one(org, new)
return {"minus": "", "result": f"{org_sms_stock} => {sms_stock}"}
Error in org_sms_stock = license_json["sms"]
The content is TypeError: list indexes must be integrers or slacks, not str
How do I solve this?
This is what json is this
[{'sms': '50', 'licanse': 'e144e7ca-6e31-4f1c-82ee-8dd473718f00'}]
The dict object is in the list object.
org_sms_stock = licanse_json[0]["sms"]
593 Uncaught (inpromise) Error on Electron: An object could not be cloned
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
573 PHP ssh2_scp_send fails to send files as intended
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
566 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.