DmitrMakeev
commited on
Commit
•
e976dab
1
Parent(s):
aa86eba
Update app.py
Browse files
app.py
CHANGED
@@ -152,7 +152,7 @@ def up_fa():
|
|
152 |
|
153 |
|
154 |
|
155 |
-
# Маршрут для обработки GET-запроса
|
156 |
@app.route('/add_contact', methods=['GET'])
|
157 |
def add_contact():
|
158 |
try:
|
@@ -174,7 +174,7 @@ def add_contact():
|
|
174 |
print(f"Error adding contact: {e}")
|
175 |
return "Internal Server Error", 500
|
176 |
|
177 |
-
# Маршрут для отображения таблицы контактов
|
178 |
@app.route('/contacts')
|
179 |
def show_contacts():
|
180 |
try:
|
@@ -232,5 +232,101 @@ def show_contacts():
|
|
232 |
print(f"Error showing contacts: {e}")
|
233 |
return "Internal Server Error", 500
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
if __name__ == '__main__':
|
236 |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
152 |
|
153 |
|
154 |
|
155 |
+
# Маршрут для обработки GET-запроса из gc
|
156 |
@app.route('/add_contact', methods=['GET'])
|
157 |
def add_contact():
|
158 |
try:
|
|
|
174 |
print(f"Error adding contact: {e}")
|
175 |
return "Internal Server Error", 500
|
176 |
|
177 |
+
# Маршрут для отображения таблицы контактов из gc
|
178 |
@app.route('/contacts')
|
179 |
def show_contacts():
|
180 |
try:
|
|
|
232 |
print(f"Error showing contacts: {e}")
|
233 |
return "Internal Server Error", 500
|
234 |
|
235 |
+
|
236 |
+
|
237 |
+
|
238 |
+
|
239 |
+
|
240 |
+
|
241 |
+
|
242 |
+
|
243 |
+
# Тестовый адрес для отправки запроса
|
244 |
+
test_url = 'https://example.com/api/endpoint'
|
245 |
+
|
246 |
+
# Переменные с данными
|
247 |
+
key_d = "LGkljg^fdlkjhgf%6kl"
|
248 |
+
action_d = "add"
|
249 |
+
params_d = ""
|
250 |
+
name_d = ""
|
251 |
+
email_d = ""
|
252 |
+
phone_d = ""
|
253 |
+
pr1_d = ""
|
254 |
+
pr2_d = ""
|
255 |
+
pr3_d = ""
|
256 |
+
|
257 |
+
@app.route('/getcurse_db', methods=['GET'])
|
258 |
+
def getcurse_db():
|
259 |
+
# Чтение параметров из GET-запроса
|
260 |
+
name_d = request.args.get('name', '')
|
261 |
+
email_d = request.args.get('email', '')
|
262 |
+
phone_d = request.args.get('phone', '')
|
263 |
+
pr1_d = request.args.get('pr1', '')
|
264 |
+
pr2_d = request.args.get('pr2', '')
|
265 |
+
pr3_d = request.args.get('pr3', '')
|
266 |
+
|
267 |
+
# Формирование JSON
|
268 |
+
json_data = {
|
269 |
+
"user": {
|
270 |
+
"email": email_d,
|
271 |
+
"phone": phone_d,
|
272 |
+
"first_name": name_d,
|
273 |
+
"addfields": {
|
274 |
+
"pr1": pr1_d,
|
275 |
+
"pr2": pr2_d,
|
276 |
+
"pr3": pr3_d
|
277 |
+
}
|
278 |
+
},
|
279 |
+
"system": {
|
280 |
+
"refresh_if_exists": 1
|
281 |
+
},
|
282 |
+
"session": {
|
283 |
+
"utm_source": "",
|
284 |
+
"utm_medium": "",
|
285 |
+
"utm_content": "",
|
286 |
+
"utm_campaign": "",
|
287 |
+
"utm_group": "",
|
288 |
+
"gcpc": "",
|
289 |
+
"gcao": "",
|
290 |
+
"referer": ""
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
# Конвертация JSON в Base64
|
295 |
+
json_str = json.dumps(json_data)
|
296 |
+
params_d = base64.b64encode(json_str.encode('utf-8')).decode('utf-8')
|
297 |
+
|
298 |
+
# Данные для отправки в теле запроса
|
299 |
+
data = {
|
300 |
+
'key': key_d,
|
301 |
+
'action': action_d,
|
302 |
+
'params': params_d
|
303 |
+
}
|
304 |
+
|
305 |
+
# Отправка POST-запроса с данными в формате "form-data"
|
306 |
+
response = requests.post(test_url, data=data)
|
307 |
+
|
308 |
+
# Возвращаем ответ от тестового адреса
|
309 |
+
return {
|
310 |
+
'status_code': response.status_code,
|
311 |
+
'response_body': response.text
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
|
316 |
+
|
317 |
+
|
318 |
+
|
319 |
+
|
320 |
+
|
321 |
+
|
322 |
+
|
323 |
+
|
324 |
+
|
325 |
+
|
326 |
+
|
327 |
+
|
328 |
+
|
329 |
+
|
330 |
+
|
331 |
if __name__ == '__main__':
|
332 |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|