Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For running Python CGI scripts in Android. Basically you needed a web server capable of running CGI scripts in Android platform but, I found none. You need toy CGI script to suit the <em>Cherrypy web server</em> and it could run on Android.</p> <p><strong>Are steps are here :</strong></p> <ol> <li>First thing we need is to download the SL4A (r4) software in the Android (2.3) emulator. It can be done from your Android browser by going to the SL4A site. Now install the software in emulator.</li> <li>Then install Python for Android from the same SL4A site. It'll download an apk of version r4.</li> <li>Launch SL4A application and check that HelloWorld python script is running. It will make sure that your installation is fine.</li> <li>Now is the time to install Cherrypy library module. It can be found at <a href="http://www.cherrypy.org/wiki/CherryPyDownload" rel="nofollow noreferrer">http://www.cherrypy.org/wiki/CherryPyDownload</a>. I have taken 3.2.0 version. Download the egg for python 2.6.</li> <li>Now we need to transfer the egg file to Android emulator. Use adb push command to transfer the egg file to /mnt/sdcard/Download.</li> <li>Launch Python for Android from emulator and click on Import modules. It will list the newly uploaded egg file. Select it and install.</li> <li>Now we can write a Cherrypy script to be run as CGI. Below is a HelloWorld example taken from Cherrypy tutorial (modified a bit) </li> </ol> <blockquote> <pre><code> # Import CherryPy global namespace import cherrypy class HelloWorld: """ Sample request handler class. """ def index(self, **params): # CherryPy will call this method for the root URI ("/") and send # its return value to the client. for key in params: print key, '=', params[key] return "Hello world!" # Expose the index method through the web. CherryPy will never # publish methods that don't have the exposed attribute set to True. index.exposed = True </code></pre> </blockquote> <pre><code># CherryPy always starts with app.root when trying to map request URIs # to objects, so we need to mount a request handler root. A request # to '/' will be mapped to HelloWorld().index(). cherrypy.config.update({'server.socket_host': '127.0.0.1'}) cherrypy.config.update({'server.socket_port': 8080}) cherrypy.quickstart(HelloWorld(), '/') </code></pre> <p>8> The script needs to be transferred to /mnt/sdcard/sl4a/scripts directory in emulator. Then you can launch SL4A and tap the script to run. Debug outputs are visible if you run in SL4A console.</p> <p>9> From the Android browser, check the URL <code>http://localhost:8080/</code>. It will say "Hello world".</p> <p>This the web server set we can place python scripts to access Android phone data and other stuff which can be exposed to the outside clients.</p> <p><strong>Credits to:</strong> <a href="http://crazytechthoughts.blogspot.in/2011/08/run-cherrypy-web-server-in-andriod.html" rel="nofollow noreferrer">see the screen shots here</a></p> <p><strong>Other Info:</strong></p> <p><a href="http://forum.xda-developers.com/showthread.php?t=1238569" rel="nofollow noreferrer">micro-httpd (GET / POST / CGI support) cross-compiled to Android</a></p> <p><a href="http://code.google.com/p/python-for-android/source/browse/python3-alpha/python3-src/Lib/cgi.py?r=b3c1049b5eadd74a307f917b3703ab6911165e4e" rel="nofollow noreferrer">python-for-android</a></p> <p><a href="http://www.lies.com/begperl/hello_cgi.html" rel="nofollow noreferrer">Running "Hello, world!" as a CGI Script</a></p> <p><strong>What I recommend:</strong></p> <p>I suggest to go for any lightweight web servers (like node.js) in raspberry pi </p> <p><strong>Ref:</strong> </p> <ul> <li><a href="http://raspberrywebserver.com/sql-databases/accessing-an-sqlite-database-with-python.html#.UjmCsUlIePs" rel="nofollow noreferrer">Raspberrry pi python</a></li> <li><a href="https://raspberrypi.stackexchange.com/questions/78/good-lightweight-web-server-framework">lightweight web servers</a></li> <li><a href="http://expressjs.com/" rel="nofollow noreferrer">web application framework for Node.js </a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload