Initial commit

This commit is contained in:
Fergal Moran
2018-09-18 01:56:13 +01:00
commit d07e68c380
6 changed files with 66 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.idea

1
.venv Normal file
View File

@@ -0,0 +1 @@
emergelope

52
app.py Normal file
View File

@@ -0,0 +1,52 @@
import os
from flask import Flask, jsonify
from twilio.rest import Client
app = Flask(__name__)
account_sid = os.environ['ACCOUNT_SID']
auth_token = os.environ['AUTH_TOKEN']
call_xml = os.environ['CALL_XML']
to_numbers = os.environ['NUMBER_LIST']
from_number = os.environ['FROM_NUMBER']
@app.route('/debuggler')
def debuggler():
return jsonify(
{
'account_sid': account_sid,
'auth_token': auth_token,
'call_xml': call_xml,
'to_numbers': to_numbers,
'from_number': from_number
}
)
@app.route('/')
def catch_all():
"""
initiate cluster fuck!!
"""
client = Client(account_sid, auth_token)
sids = []
for number in to_numbers.split(','):
try:
sids.append(
client.calls.create(
to=number,
from_=from_number,
url=call_xml,
method='GET'
)
)
except:
print('Error sending message')
return sids
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8081)

4
emergency.xml Normal file
View File

@@ -0,0 +1,4 @@
<Response>
<Say voice="alice">Don't panic! Penny has pulled the emergency ripcord, please call Fergal!</Say>
<Play>http://demo.twilio.com/docs/classic.mp3</Play>
</Response>

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
Flask
twilio

6
server.py Normal file
View File

@@ -0,0 +1,6 @@
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"