DmitrMakeev
commited on
Commit
•
df9fd6c
1
Parent(s):
e0e0f15
Update app.py
Browse files
app.py
CHANGED
@@ -1074,6 +1074,106 @@ def gc_db_email():
|
|
1074 |
except Exception as e:
|
1075 |
print(f"Error in gc_db_email: {e}")
|
1076 |
return "Internal Server Error", 500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1077 |
|
1078 |
|
1079 |
|
|
|
1074 |
except Exception as e:
|
1075 |
print(f"Error in gc_db_email: {e}")
|
1076 |
return "Internal Server Error", 500
|
1077 |
+
|
1078 |
+
|
1079 |
+
|
1080 |
+
|
1081 |
+
|
1082 |
+
|
1083 |
+
|
1084 |
+
|
1085 |
+
|
1086 |
+
|
1087 |
+
|
1088 |
+
|
1089 |
+
|
1090 |
+
@app.route('/gc_forms', methods=['GET'])
|
1091 |
+
def gc_forms():
|
1092 |
+
try:
|
1093 |
+
api_sys_control = request.args.get('api_sys')
|
1094 |
+
|
1095 |
+
if api_sys_control != api_key_sys:
|
1096 |
+
return "EUR 22", 200
|
1097 |
+
|
1098 |
+
# Чтение параметров из GET-запроса
|
1099 |
+
name_d = request.args.get('name', '')
|
1100 |
+
email_d = request.args.get('email', '')
|
1101 |
+
phone_d = request.args.get('phone', '')
|
1102 |
+
pr1_d = request.args.get('pr1', '')
|
1103 |
+
pr2_d = request.args.get('pr2', '')
|
1104 |
+
pr3_d = request.args.get('pr3', '')
|
1105 |
+
|
1106 |
+
# Формирование JSON
|
1107 |
+
json_data = {
|
1108 |
+
"user": {
|
1109 |
+
"email": email_d,
|
1110 |
+
"phone": phone_d,
|
1111 |
+
"first_name": name_d,
|
1112 |
+
"addfields": {
|
1113 |
+
"pr1": pr1_d,
|
1114 |
+
"pr2": pr2_d,
|
1115 |
+
"pr3": pr3_d
|
1116 |
+
}
|
1117 |
+
},
|
1118 |
+
"system": {
|
1119 |
+
"refresh_if_exists": 1
|
1120 |
+
},
|
1121 |
+
"session": {
|
1122 |
+
"utm_source": "",
|
1123 |
+
"utm_medium": "",
|
1124 |
+
"utm_content": "",
|
1125 |
+
"utm_campaign": "",
|
1126 |
+
"utm_group": "",
|
1127 |
+
"gcpc": "",
|
1128 |
+
"gcao": "",
|
1129 |
+
"referer": ""
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
# Конвертация JSON в Base64
|
1134 |
+
json_str = json.dumps(json_data)
|
1135 |
+
params_d = base64.b64encode(json_str.encode('utf-8')).decode('utf-8')
|
1136 |
+
|
1137 |
+
# Данные для отправки в теле запроса
|
1138 |
+
data = {
|
1139 |
+
'key': gc_api,
|
1140 |
+
'action': action_d,
|
1141 |
+
'params': params_d
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
# Отправка POST-запроса с данными в формате "form-data"
|
1145 |
+
response = requests.post(gc_url, data=data)
|
1146 |
+
|
1147 |
+
# Возвращаем ответ от тестового адреса
|
1148 |
+
return {
|
1149 |
+
'status_code': response.status_code,
|
1150 |
+
'response_body': response.text
|
1151 |
+
}
|
1152 |
+
except Exception as e:
|
1153 |
+
print(f"Error in gc_db_email: {e}")
|
1154 |
+
return "Internal Server Error", 500
|
1155 |
+
|
1156 |
+
|
1157 |
+
|
1158 |
+
|
1159 |
+
|
1160 |
+
|
1161 |
+
|
1162 |
+
|
1163 |
+
|
1164 |
+
|
1165 |
+
|
1166 |
+
|
1167 |
+
|
1168 |
+
|
1169 |
+
|
1170 |
+
|
1171 |
+
|
1172 |
+
|
1173 |
+
|
1174 |
+
|
1175 |
+
|
1176 |
+
|
1177 |
|
1178 |
|
1179 |
|