Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
0a3e3b6
1
Parent(s):
05035e7
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ app = Flask(__name__, template_folder="./")
|
|
6 |
|
7 |
base_url = os.getenv('base_url') # URL сервера
|
8 |
token = os.getenv('token') # Ваш токен
|
|
|
|
|
9 |
|
10 |
@app.route('/grups', methods=['GET'])
|
11 |
def grup():
|
@@ -27,50 +29,54 @@ def send_request():
|
|
27 |
@app.route('/save_db', methods=['GET'])
|
28 |
def save_db():
|
29 |
show_params = False
|
30 |
-
|
31 |
name = request.args.get('name')
|
32 |
-
|
|
|
33 |
phone = request.args.get('phone')
|
34 |
-
|
35 |
pr1 = request.args.get('pr1')
|
|
|
36 |
pr2 = request.args.get('pr2')
|
|
|
37 |
pr3 = request.args.get('pr3')
|
|
|
38 |
data = {
|
39 |
"email": email,
|
40 |
"unconfirmed": False,
|
41 |
"values": [
|
42 |
{
|
43 |
-
"parameter_id":
|
44 |
"kind": "string",
|
45 |
"list_id": 557103,
|
46 |
"title": "pr3",
|
47 |
"value": pr3
|
48 |
},
|
49 |
{
|
50 |
-
"parameter_id":
|
51 |
"kind": "string",
|
52 |
-
"list_id":
|
53 |
"title": "pr2",
|
54 |
"value": pr2
|
55 |
},
|
56 |
{
|
57 |
-
"parameter_id":
|
58 |
"kind": "string",
|
59 |
-
"list_id":
|
60 |
"title": "pr1",
|
61 |
"value": pr1
|
62 |
},
|
63 |
{
|
64 |
-
"parameter_id":
|
65 |
"kind": "string",
|
66 |
-
"list_id":
|
67 |
"title": "phone",
|
68 |
"value": phone
|
69 |
},
|
70 |
{
|
71 |
-
"parameter_id":
|
72 |
"kind": "string",
|
73 |
-
"list_id":
|
74 |
"title": "name",
|
75 |
"value": name
|
76 |
}
|
@@ -81,7 +87,7 @@ def save_db():
|
|
81 |
'Authorization': f'Bearer {token}',
|
82 |
'Content-Type': 'application/json'
|
83 |
}
|
84 |
-
response = requests.post(f"{base_url}/email/lists/{
|
85 |
|
86 |
if show_params:
|
87 |
system_vars = {
|
@@ -90,7 +96,7 @@ def save_db():
|
|
90 |
}
|
91 |
return jsonify({'system_variables': system_vars, 'request_parameters': request.args})
|
92 |
else:
|
93 |
-
return
|
94 |
|
95 |
if __name__ == '__main__':
|
96 |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
6 |
|
7 |
base_url = os.getenv('base_url') # URL сервера
|
8 |
token = os.getenv('token') # Ваш токен
|
9 |
+
api_key = os.getenv('api_key') # Ваш
|
10 |
+
|
11 |
|
12 |
@app.route('/grups', methods=['GET'])
|
13 |
def grup():
|
|
|
29 |
@app.route('/save_db', methods=['GET'])
|
30 |
def save_db():
|
31 |
show_params = False
|
32 |
+
list_id = request.args.get('list_id')
|
33 |
name = request.args.get('name')
|
34 |
+
name_id = request.args.get('name_id')
|
35 |
+
email = request.args.get('email')
|
36 |
phone = request.args.get('phone')
|
37 |
+
phone_id = request.args.get('phone_id')
|
38 |
pr1 = request.args.get('pr1')
|
39 |
+
pr1_id = request.args.get('pr1_id')
|
40 |
pr2 = request.args.get('pr2')
|
41 |
+
pr2_id = request.args.get('pr2_id')
|
42 |
pr3 = request.args.get('pr3')
|
43 |
+
pr3_id = request.args.get('pr3_id')
|
44 |
data = {
|
45 |
"email": email,
|
46 |
"unconfirmed": False,
|
47 |
"values": [
|
48 |
{
|
49 |
+
"parameter_id": pr3_id,
|
50 |
"kind": "string",
|
51 |
"list_id": 557103,
|
52 |
"title": "pr3",
|
53 |
"value": pr3
|
54 |
},
|
55 |
{
|
56 |
+
"parameter_id": pr2_id,
|
57 |
"kind": "string",
|
58 |
+
"list_id": list_id,
|
59 |
"title": "pr2",
|
60 |
"value": pr2
|
61 |
},
|
62 |
{
|
63 |
+
"parameter_id": pr1_id,
|
64 |
"kind": "string",
|
65 |
+
"list_id": list_id,
|
66 |
"title": "pr1",
|
67 |
"value": pr1
|
68 |
},
|
69 |
{
|
70 |
+
"parameter_id": phone_id,
|
71 |
"kind": "string",
|
72 |
+
"list_id": list_id,
|
73 |
"title": "phone",
|
74 |
"value": phone
|
75 |
},
|
76 |
{
|
77 |
+
"parameter_id": name_id,
|
78 |
"kind": "string",
|
79 |
+
"list_id": list_id,
|
80 |
"title": "name",
|
81 |
"value": name
|
82 |
}
|
|
|
87 |
'Authorization': f'Bearer {token}',
|
88 |
'Content-Type': 'application/json'
|
89 |
}
|
90 |
+
response = requests.post(f"{base_url}/email/lists/{list_id}/recipients", json=data, headers=headers)
|
91 |
|
92 |
if show_params:
|
93 |
system_vars = {
|
|
|
96 |
}
|
97 |
return jsonify({'system_variables': system_vars, 'request_parameters': request.args})
|
98 |
else:
|
99 |
+
return response.text
|
100 |
|
101 |
if __name__ == '__main__':
|
102 |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|