Running CherryPy on Android with SL4A

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:

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:

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 for example. Copy that file into the scripts directory of SL4A.

Unplug your phone and go to the SL4A application. Click on the 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.

12 thoughts on “Running CherryPy on Android with SL4A”

  1. This is so fun. I am sending python code from my browser and eval-ing it on the phone. This is great for exploring and playing around with the methods like ttsSpeak.

  2. very cool!

    i am looking at a way of doing something similar in Lua, any pointers?

    obviously the task here on Python is much easier since cherrypy has its own self-contained environment, Lua is going to be a bit more work, but i think i can get there.

  3. I cant wait to run Web2py on my android 8 inches and 9 inches tablet and develop inside there. And awesome, i found this tutorial and it helps. Thanks for posting.

  4. Sorry to be a bit confused, what os are you doing this on? where are u suppose to type these commands in?

Comments are closed.