-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwilio.py
30 lines (24 loc) · 869 Bytes
/
twilio.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
from flask import Flask, send_from_directory, make_response, render_template
# from twilio import twiml
import xml.etree.ElementTree as ET
app = Flask(__name__, static_folder='xml', static_url_path='/')
# reading xml from disk
twiml = ET.parse('xml/twilio.xml')
root = twiml.getroot()
print root.tag
for child in root:
print child.tag, child.attrib
@app.route('/')
def hello_twilio():
return 'Hello, world!'
@app.route('/inbound')
def twilio_response():
response = make_response(open("xml/twilio.xml").read())
response.headers['Content-Type'] = 'application/xml'
return response
#return send_from_directory('xml', 'twilio.xml', as_attachment=True)
#number = request.form['From']
#message_body = request.form['Body']
#resp = twiml.Response()
#resp.message('Hello world!'.format(number, message_body))
#return str(resp)