|
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') |
|
token = os.getenv('token') |
|
|
|
@app.route('/save_db', methods=['GET']) |
|
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))) |