Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tweeks

  • Loading branch information...
commit 21b3e0b0884848f38a6155724f53b182785d467e 1 parent a6f5ce1
@chadselph chadselph authored
Showing with 21 additions and 9 deletions.
  1. +13 −7 docs/browser.rst
  2. +8 −2 main.py
View
20 docs/browser.rst
@@ -69,14 +69,11 @@ new AppEngine RequestHandler into ``main.py``.
.. code-block:: python
- import os
-
-
class IndexPage(webapp2.RequestHandler):
def get(self):
params = {
- "token": gen_token("ACXXX", "XXX", "APXXX")
+ "token": gen_token(ACCOUNT_SID, AUTH_TOKEN, APP_SID)
}
self.response.out.write(render_template("index.html", params))
@@ -158,13 +155,22 @@ Let's add a feature where we can see a visualization of the queue
.. code-block:: python
- some python code that queries the queue
+ import json
+ from twilio import TwilioRestClient
+
+ class QueueStatusPage(webapp2.RequestHandler):
+
+ def get(self):
+ client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
+ q_data = {"queues": client.queues.get(QUEUE_SID)}
+ self.response.out.write(json.dumps(q_data))
+Add this QueueStatusPage into the WSIApplication's routing map as ``/queue-status``.
Now we need some Javascript to poll the state of the queue and update the UI.
.. code-block:: javascript
- $.get("/queue-status", function() {
-
+ $.get("/queue-status", function(result) {
+ // update your UI here
});
View
10 main.py
@@ -1,10 +1,16 @@
-import webapp2
-from google.appengine.ext.webapp import template
import os
+from google.appengine.ext.webapp import template
+import twilio
+import webapp2
+
+ACCOUNT_SID = "ACXXX"
+AUTH_TOKEN = "XXX"
+APP_SID = "APXXX"
# Utility functions
+
def render_template(rel_path, parameters=None, folder="templates"):
"""
Takes a path relative to the templates/ folder and
Please sign in to comment.
Something went wrong with that request. Please try again.