DmitrMakeev
commited on
Commit
•
69c0b8c
1
Parent(s):
5c967ee
Update app.py
Browse files
app.py
CHANGED
@@ -78,11 +78,10 @@ def init_db(db_name):
|
|
78 |
pr3 TEXT NOT NULL,
|
79 |
pr4 TEXT NOT NULL,
|
80 |
pr5 TEXT NOT NULL,
|
81 |
-
ad_url TEXT NOT
|
82 |
key_pr TEXT NOT NULL,
|
83 |
canal TEXT NOT NULL,
|
84 |
data_t TEXT NOT NULL
|
85 |
-
|
86 |
)
|
87 |
''')
|
88 |
conn.commit()
|
@@ -98,6 +97,7 @@ for db in DATABASES:
|
|
98 |
|
99 |
|
100 |
|
|
|
101 |
# Функция для выполнения HTTP запросов
|
102 |
def fetch(url):
|
103 |
try:
|
@@ -212,18 +212,6 @@ def export_user():
|
|
212 |
|
213 |
|
214 |
|
215 |
-
def send_second_request(export_id):
|
216 |
-
if export_id is None:
|
217 |
-
raise Exception("export_id is None")
|
218 |
-
# Формирование URL для второго запроса
|
219 |
-
export_url_template = f"https://school.riverpsy.com/pl/api/account/exports/{export_id}?key=jqgxSMUnHWoKUcxF3MHSb77VUMk7HpFbO9SHnfVYwHtwqe1S81lqeKxrLPoSPWCephtYQuJwMFsCXEFmyByXdruDpDFgf6L7ij66K9ji0Kf2qAIwbTqEyJGB5MOHwyHl"
|
220 |
-
try:
|
221 |
-
response = requests.get(export_url_template)
|
222 |
-
response.raise_for_status()
|
223 |
-
return response.json() # Возвращаем JSON-ответ сервера
|
224 |
-
except requests.RequestException as e:
|
225 |
-
raise Exception(f"Ошибка при выполнении запроса: {e}")
|
226 |
-
|
227 |
def load_data_from_json(json_data):
|
228 |
data = json_data
|
229 |
items = data['info']['items']
|
@@ -250,6 +238,9 @@ def load_data_from_json(json_data):
|
|
250 |
user_data.setdefault('pr4', '')
|
251 |
user_data.setdefault('pr5', '')
|
252 |
user_data.setdefault('ad_url', '')
|
|
|
|
|
|
|
253 |
|
254 |
# Убираем плюс в начале телефона, если он присутствует
|
255 |
if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
|
@@ -257,9 +248,9 @@ def load_data_from_json(json_data):
|
|
257 |
|
258 |
query = '''
|
259 |
INSERT INTO contacts (
|
260 |
-
|
261 |
) VALUES (
|
262 |
-
|
263 |
)
|
264 |
'''
|
265 |
cursor.execute(query, user_data)
|
@@ -267,6 +258,7 @@ def load_data_from_json(json_data):
|
|
267 |
conn.commit()
|
268 |
conn.close()
|
269 |
|
|
|
270 |
@app.route('/start', methods=['GET'])
|
271 |
def start():
|
272 |
export_id = request.args.get('export_id')
|
|
|
78 |
pr3 TEXT NOT NULL,
|
79 |
pr4 TEXT NOT NULL,
|
80 |
pr5 TEXT NOT NULL,
|
81 |
+
ad_url TEXT NOT NULL,
|
82 |
key_pr TEXT NOT NULL,
|
83 |
canal TEXT NOT NULL,
|
84 |
data_t TEXT NOT NULL
|
|
|
85 |
)
|
86 |
''')
|
87 |
conn.commit()
|
|
|
97 |
|
98 |
|
99 |
|
100 |
+
|
101 |
# Функция для выполнения HTTP запросов
|
102 |
def fetch(url):
|
103 |
try:
|
|
|
212 |
|
213 |
|
214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
def load_data_from_json(json_data):
|
216 |
data = json_data
|
217 |
items = data['info']['items']
|
|
|
238 |
user_data.setdefault('pr4', '')
|
239 |
user_data.setdefault('pr5', '')
|
240 |
user_data.setdefault('ad_url', '')
|
241 |
+
user_data.setdefault('key_pr', '')
|
242 |
+
user_data.setdefault('canal', '')
|
243 |
+
user_data.setdefault('data_t', '')
|
244 |
|
245 |
# Убираем плюс в начале телефона, если он присутствует
|
246 |
if 'Телефон' in user_data and user_data['Телефон'].startswith('+'):
|
|
|
248 |
|
249 |
query = '''
|
250 |
INSERT INTO contacts (
|
251 |
+
name, phone, email, vk_id, chat_id, ws_statys, ws_stop, web_statys, fin_progress, shop_statys_full, pr1, pr2, pr3, pr4, pr5, ad_url, curator, key_pr, canal, data_t
|
252 |
) VALUES (
|
253 |
+
:Имя, :Телефон, :Email, :vk_id, :chat_id, :ws_st, :ws_stop, :web_st, :fin_prog, :shop_st, :pr1, :pr2, :pr3, :pr4, :pr5, :ad_url, :curator, :key_pr, :canal, :data_t
|
254 |
)
|
255 |
'''
|
256 |
cursor.execute(query, user_data)
|
|
|
258 |
conn.commit()
|
259 |
conn.close()
|
260 |
|
261 |
+
|
262 |
@app.route('/start', methods=['GET'])
|
263 |
def start():
|
264 |
export_id = request.args.get('export_id')
|