CherryPy runs on Android thanks to the SL4A project. So if you feel like running Python and your own web server on your Android device, well you can just do so. You’ve probably not heard something that awesome since the pizza delivery guy rung the door.
How to get on about it? Well that’s the surprise, CherryPy in itself doesn’t need to be patched. Granted I haven’t tried all the various tools provided by CherryPy but the server and the dispatching works just fine.
First, you need get the CherryPy source code, build and copy the resulting cherrypy package into the SL4A scripts directory.
Once you’ve plugged your phone to your machine through USB, run the next commands:
$ svn co http://svn.cherrypy.org/trunk cp3-trunk
$ cd cp3-trunk
$ python setup.py build
$ cp -r build/lib.linux-i686-2.6/cherrypy/ /media/usb0/sl4a/scripts/
Just change the path to match your environment.Â That’s it.
Now you can copy your own script, let’s assume you use something like below:
# -*- coding: utf-8 -*-
# The multiprocessing package isn't
# part of the ASE installation so
# we must disable multiprocessing logging
logging.logMultiprocessing = 0
self.droid = android.Android()
return "Hello from my phone"
location = self.droid.getLastKnownLocation().result
location = location.get('network', location.get('gps'))
return "LAT: %s, LON: %s" % (location['latitude'],
if __name__ == '__main__':
As you can see we must disable the multiprocessing logging since the multiprocessing package isn’t included with SL4A.
Save that script on your computer as cpdroid.py for example. Copy that file into the scripts directory of SL4A.
$ cp cpdroid.py /media/usb0/sl4a/scripts/
Unplug your phone and go to the SL4A application. Click on the cpdroid.py script, it should start fine. Then from your browser, go to http://phone_IP:8080/ and tada! You can also go to the /location path to get the geoloc of your phone.