Spaces:
Sleeping
Sleeping
from flask import Flask, request, jsonify | |
from flask import Flask, request | |
import requests | |
import os | |
app = Flask(__name__) | |
api_key = os.getenv('api_key') | |
base_url = os.getenv('base_url') # URL сервера, например, 'https://api.notisend.ru/v1/email/' | |
token = os.getenv('token') # Ваш токен | |
def save_db(): | |
# Получаем данные из запроса | |
name = request.args.get('name') | |
email = request.args.get('email') | |
phone = request.args.get('phone') | |
grup_id = request.args.get('grup_id') | |
pr1 = request.args.get('pr1') | |
pr2 = request.args.get('pr2') | |
# Создаем данные для отправки | |
data = { | |
"email": email, | |
"unconfirmed": True, # Создаем неподтвержденного получателя | |
"values": [ | |
{"parameter_id": "name", "value": name}, | |
{"parameter_id": "phone", "value": phone}, | |
{"parameter_id": "utm1", "value": pr1}, | |
{"parameter_id": "utm2", "value": pr2} | |
], | |
"tags": ["buyer", "regular customer"] # Пример тегов | |
} | |
# Отправляем запрос | |
headers = { | |
'Authorization': f'Bearer {token}', | |
'Content-Type': 'application/json' | |
} | |
response = requests.post(f"{base_url}lists/{grup_id}/recipients", json=data, headers=headers) | |
# Возвращаем текст ответа сервера | |
return response.text | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860))) |