-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook.py
36 lines (31 loc) · 1 KB
/
webhook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from flask import Flask, request
from twilio.rest import Client
import os
from token import account_sid, auth_token
#Nueva versión
client = Client(account_sid, auth_token)
# Initialize Flask app
app = Flask(__name__)
@app.route('/', methods=['GET'])
def home():
return "Deltix webhook server is running!"
@app.route('/webhook', methods=['GET', 'POST'])
def webhook():
if request.method == 'POST':
# Handle POST request (Twilio webhook)
message = client.messages.create(
from_='whatsapp:+14155238886',
body='123 Probando',
to='whatsapp:+5491151128207'
)
return str(message)
else:
# Handle GET request (browser access)
return "Deltix webhook endpoint is active. Send a POST request to use it."
# For local development
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)
else:
# This is the code that will be used by PythonAnywhere
# Make sure to configure your WSGI file to point to this application
application = app