Powered By Blogger

Wednesday 23 May 2012

Creating a local server on the Android phone.

Lets us unleash the potential of the ANDROID BEAST!!!- 1st exercise

     Creating a server so that we can access the directories of our like from the phone directly through the browser!! no need of USB cable and the sluggish Kies (coz i own a Samsung galaxy S ) (:

Step1:  To find IP address of the phone.
  1.     Open SL4A application(find the installation guide here )
  2.      Tap the "menu" key then "View"
  3.     Select "Interpreters"
  4.     Open the "Shell"

        Make sure internet is working. Type "netcfg" in the shell, now the result will be something like this:                       

            lo              UP        127.0.0.1       255.0.0.0       0x00000049

             svnet0     UP         0.0.0.0           0.0.0.0         0x000000d1                            

             ifb0          DOWN  0.0.0.0          0.0.0.0         0x00000082                            

             ifb1          DOWN  0.0.0.0          0.0.0.0         0x00000082

             usb0        DOWN  0.0.0.0          0.0.0.0         0x00001002                            

             sit0          DOWN  0.0.0.0          0.0.0.0         0x00000080                           

             ip6tnl0    DOWN  0.0.0.0          0.0.0.0         0x00000080                            

             eth0         UP        192.168.1.6     255.255.255.0   0x00001043                    

      Leave the first line "lo" and look for the remaining having "UP" next to them. In my case the IP is 192.168.1.6

Step2: Create a script having the following code:

     import SimpleHTTPServer
     from os import chdir
     chdir('/sdcard/DCIM/Camera/')
     SimpleHTTPServer.test()

Save and Run the code and open the browser on your computer and type:

           your IP address:Portaddress i.e, 192.168.1.6:8000 in my case.

By default android uses port address 8000.
Now u should be able to see the contents of the "Camera" folder. You can change this to any other directory. Right Click on any link and save it.

       Hope you enjoyed it:)

No comments:

Post a Comment