Building the Basic Application

To demonstrate some basic SMS functionality, we’re going to build an application that can handle sending and receiving SMS messages from two different SMS API providers. This application will look and feel very similar to the instant messaging application from the previous chapter, with the main differences lying in how the user interacts with the application and how our code sends and receives the messages.

Extending the Instant Messaging Application

This type of application is another perfect candidate to run on Google’s App Engine platform. However, rather than register and create a new application, we’ll just extend the existing application to send and receive SMS messages in addition to its existing functionality to handle instant messages via XMPP. At the moment, any URL request that comes into the instant messaging application is handled by the main.py file, as we specified in our configuration. To handle the SMS requests, we’ll segment everything off into URLs that start with the /sms/ path. We can even create a new Python file to handle all of those requests. To set up this configuration, make the following change to your app.yaml file:

application: your-application-id
version: 1
runtime: python
api_version: 1

handlers:
- url: /sms/.*
  script: sms.py

- url: .*
  script: main.py

...

This change tells App Engine to send any request starting with /sms/ to the sms.py file. If the URL does not match that pattern, it will be picked up by the much more ...

Get Building the Realtime User Experience now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.