8.7. Using a Phone as a Web Service
Accessing the phone's resources by way of the web is a 'bleeding-edge' approach that might be used as a springboard for many kinds of unprecedented applications.
We have already seen some examples where a PyS60 program fetches some information from the web. Many more examples along these lines follow in Chapter 9. In this section, however, we consider the opposite case: the phone could serve information to the web (see Figure 8.7).
Figure 8-7. Phone providing a web service
Think about various possibilities: for example, you could take a photo with someone else's camera phone from a web page, you could request the phone's holder in real time to take a photo for you or your mobile website could list people around you at that moment, based on Bluetooth scanning.
Apache, the world's most popular web server, has been ported to the S60 platform so one can experiment with scenarios like this. You could use Mobile Web Server (MWS) to implement the above scenarios. You can even use PyS60 to write extensions and request handlers for the server. You can find the MWS home page at http://opensource.nokia.com/projects/mobile-web-server/.
Here, however, we show you how to serve resources of your mobile phone to the web in pure PyS60. Compared to MWS, this approach is more flexible since you can control every part of the server. On the other hand, in some ...
Get Mobile Python: Rapid Prototyping of Applications on the Mobile Platform 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.