Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1061,14 +1061,12 @@ def get_order():
|
|
1061 |
return json.dumps({"error": "Invalid signature"}), 400
|
1062 |
|
1063 |
# Подключаемся к базе данных
|
1064 |
-
logging.debug(f"Connecting to database {DATABASE_NEW}")
|
1065 |
conn = sqlite3.connect(DATABASE_NEW)
|
1066 |
cursor = conn.cursor()
|
1067 |
|
1068 |
# Ищем запись по vk_id
|
1069 |
cursor.execute("SELECT orders FROM contacts WHERE vk_id = ?", (vkid,))
|
1070 |
result = cursor.fetchone()
|
1071 |
-
logging.debug(f"Database query result: {result}")
|
1072 |
|
1073 |
# Если запись по vk_id не найдена, возвращаем значение "not" для ордера
|
1074 |
if not result:
|
@@ -1076,19 +1074,12 @@ def get_order():
|
|
1076 |
response = {order: 'not'}
|
1077 |
return jsonify(response), 200
|
1078 |
|
1079 |
-
# Извлекаем данные из результата
|
1080 |
shop_st = result[0] if result[0] else '{}'
|
1081 |
-
|
1082 |
-
|
1083 |
-
shop_st_data = json.loads(shop_st)
|
1084 |
-
logging.debug(f"Parsed shop_st data: {shop_st_data}")
|
1085 |
-
except json.JSONDecodeError as e:
|
1086 |
-
logging.error(f"Error parsing JSON: {e}")
|
1087 |
-
return json.dumps({"error": "Error parsing JSON"}), 500
|
1088 |
|
1089 |
# Ищем значение по ключу order
|
1090 |
value = shop_st_data.get(order, 'not')
|
1091 |
-
logging.debug(f"Order value: {value}")
|
1092 |
|
1093 |
# Возвращаем данные из столбца
|
1094 |
response = {order: value}
|
|
|
1061 |
return json.dumps({"error": "Invalid signature"}), 400
|
1062 |
|
1063 |
# Подключаемся к базе данных
|
|
|
1064 |
conn = sqlite3.connect(DATABASE_NEW)
|
1065 |
cursor = conn.cursor()
|
1066 |
|
1067 |
# Ищем запись по vk_id
|
1068 |
cursor.execute("SELECT orders FROM contacts WHERE vk_id = ?", (vkid,))
|
1069 |
result = cursor.fetchone()
|
|
|
1070 |
|
1071 |
# Если запись по vk_id не найдена, возвращаем значение "not" для ордера
|
1072 |
if not result:
|
|
|
1074 |
response = {order: 'not'}
|
1075 |
return jsonify(response), 200
|
1076 |
|
|
|
1077 |
shop_st = result[0] if result[0] else '{}'
|
1078 |
+
shop_st_data = json.loads(shop_st)
|
1079 |
+
logging.debug(f"Existing record found. Loaded JSON: {shop_st_data}")
|
|
|
|
|
|
|
|
|
|
|
1080 |
|
1081 |
# Ищем значение по ключу order
|
1082 |
value = shop_st_data.get(order, 'not')
|
|
|
1083 |
|
1084 |
# Возвращаем данные из столбца
|
1085 |
response = {order: value}
|