Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
4818e9b
1
Parent(s):
95f07ef
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from flask import Flask, request, jsonify
|
|
|
2 |
import requests
|
3 |
import os
|
4 |
|
@@ -10,47 +11,36 @@ token = os.getenv('token') # Ваш токен
|
|
10 |
|
11 |
@app.route('/save_db', methods=['GET'])
|
12 |
def save_db():
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
"
|
29 |
-
"
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
}
|
44 |
-
response = requests.post(f"{base_url}lists/{grup_id}/recipients", json=data, headers=headers)
|
45 |
-
|
46 |
-
# Проверяем статус ответа
|
47 |
-
if response.status_code == 200:
|
48 |
-
return jsonify({"status": "success", "message": "Recipient created successfully"}), 200
|
49 |
-
else:
|
50 |
-
return jsonify({"status": "error", "message": f"Error: {response.status_code} - {response.text}"}), 400
|
51 |
-
|
52 |
-
else:
|
53 |
-
return jsonify({"status": "error", "message": "Invalid API key"}), 401
|
54 |
|
55 |
|
56 |
|
|
|
1 |
from flask import Flask, request, jsonify
|
2 |
+
from flask import Flask, request
|
3 |
import requests
|
4 |
import os
|
5 |
|
|
|
11 |
|
12 |
@app.route('/save_db', methods=['GET'])
|
13 |
def save_db():
|
14 |
+
# Получаем данные из запроса
|
15 |
+
name = request.args.get('name')
|
16 |
+
email = request.args.get('email')
|
17 |
+
phone = request.args.get('phone')
|
18 |
+
grup_id = request.args.get('grup_id')
|
19 |
+
pr1 = request.args.get('pr1')
|
20 |
+
pr2 = request.args.get('pr2')
|
21 |
+
|
22 |
+
# Создаем данные для отправки
|
23 |
+
data = {
|
24 |
+
"email": email,
|
25 |
+
"unconfirmed": True, # Создаем неподтвержденного получателя
|
26 |
+
"values": [
|
27 |
+
{"parameter_id": "name", "value": name},
|
28 |
+
{"parameter_id": "phone", "value": phone},
|
29 |
+
{"parameter_id": "utm1", "value": pr1},
|
30 |
+
{"parameter_id": "utm2", "value": pr2}
|
31 |
+
],
|
32 |
+
"tags": ["buyer", "regular customer"] # Пример тегов
|
33 |
+
}
|
34 |
+
|
35 |
+
# Отправляем запрос
|
36 |
+
headers = {
|
37 |
+
'Authorization': f'Bearer {token}',
|
38 |
+
'Content-Type': 'application/json'
|
39 |
+
}
|
40 |
+
response = requests.post(f"{base_url}lists/{grup_id}/recipients", json=data, headers=headers)
|
41 |
+
|
42 |
+
# Возвращаем текст ответа сервера
|
43 |
+
return response.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
|