forked from markormesher/noisy-tweets
-
Notifications
You must be signed in to change notification settings - Fork 1
/
twilioserver.py
35 lines (25 loc) · 850 Bytes
/
twilioserver.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
import web
from config import *
urls = ('/sound.xml', 'soundxml',
'/changetone/([0-9]+)/(.+)', 'changetone')
app = web.application(urls, globals())
tone = 50
class changetone:
def GET(self, newtone, secret):
if TWILIO_SERVER_SECRET != secret:
return False
global tone
tone = newtone
return True
class soundxml:
def GET(self):
web.header('Content-Type', 'text/xml')
response = ''
response += '<?xml version="1.0" encoding="UTF-8"?>'
response += '<Response>'
response += '<Play>' + TWILIO_SERVER_URL + '/static/sound/' + str(tone) + '.mp3</Play>'
response += '<Redirect method="GET">' + TWILIO_SERVER_URL + '/sound.xml</Redirect>'
response += '</Response>'
return response
if __name__ == '__main__':
app.run()