Skip to content

Commit

Permalink
Made it better for PSTN
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrnocswift committed Dec 5, 2014
1 parent a43b5e2 commit 26baf24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Twilio Mobile Quickstart",
"description": "A simple Python server to distribute capability tokens and route calls for your mobile app",
"repository": "https://github.com/vassjozsef/mobile-quickstart",
"repository": "https://github.com/gtrnocswift/mobile-quickstart",
"logo": "https://static1.twilio.com/packages/company/img/logos_icon_round.png",
"keywords": [
"twilio",
Expand All @@ -24,6 +24,10 @@
"CALLER_ID": {
"description": "Phone number verified with your Twilio Account",
"required": true
},
"PSTN_ENDPOINT": {
"description": "Name of client to connect to from PSTN",
"required": true
}
}
}
7 changes: 4 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
APP_SID = 'APZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'

CALLER_ID = '+12345678901'
CLIENT = 'jenny'
PSTN_ENDPOINT = 'jenny'

app = Flask(__name__)
pstn_endpoint = os.environ.get("PSTN_ENDPOINT", PSTN_ENDPOINT)

This comment has been minimized.

Copy link
@vassjozsef

vassjozsef Dec 18, 2014

Please move this to call() right before it used.


@app.route('/token', strict_slashes=False)
def token():
Expand Down Expand Up @@ -41,7 +42,7 @@ def call():
""" Rules: 1. From can be either client:name or PSTN number """
""" 2. To value specifies target. When call is coming """
""" from PSTN, To value is ignored and call is """
""" routed to client named CLIENT """
""" routed to client from pstn_endpoint """
resp = twilio.twiml.Response()
from_value = request.values.get('From')
to = request.values.get('To')
Expand All @@ -51,7 +52,7 @@ def call():
caller_id = os.environ.get("CALLER_ID", CALLER_ID)
if not from_client:
# PSTN -> client
resp.dial(callerId=from_value).client(CLIENT)
resp.dial(callerId=from_value).client(pstn_endpoint)
elif to.startswith("client:"):
# client -> client
resp.dial(callerId=from_value).client(to[7:])
Expand Down

0 comments on commit 26baf24

Please sign in to comment.