Skip to content

Commit

Permalink
tweeks
Browse files Browse the repository at this point in the history
  • Loading branch information
chadselph committed Oct 12, 2012
1 parent a6f5ce1 commit 21b3e0b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
20 changes: 13 additions & 7 deletions docs/browser.rst
Expand Up @@ -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))
Expand Down Expand Up @@ -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
});
10 changes: 8 additions & 2 deletions 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
Expand Down

0 comments on commit 21b3e0b

Please sign in to comment.