def get(self):
try:
args = parser.parse_args()
except Exception:
return abort(400, message="Invalid arguments")
with db:
with db.cursor() as cursor:
user_id = get_or_create_id(args['token'])
cursor.execute(
"SELECT fridge_items.ean, products.name, products.type FROM fridge_items"
" JOIN products ON products.ean=fridge_items.ean"
" WHERE fridge_items.user_id=%s",
[user_id[0]])
response = []
for item in cursor.fetchall():
response.append({'ean': item[0],
'name': item[1],
'type': item[2]})
return response, 200
评论列表
文章目录