[Guide] Turn Android into a file server
Python is one of the simple yet powerful languages which comes in handy at every level. The large number of utilities , libraries and packages provided makes it very versatile and flexible.
SimpleHTTPServer is one of the features of python that can be used to host a simple HTTP file server , avaiable for Windows and Linux platforms.
Transfering files from your droid device might sometimes be painful. You might have to plug-in the cables and switch some of the keys and then always careful while unplugging them too.
Is there a better way ?
So , here is a solution !
Requisites :
It is a python compiler available for Android devices. It is free and available at the playstore.
* The android device and the computer to which we are transferring the file should be connected to the same network.
An application that can monitor A-Z !
Procedure :
* Install both the applications mentioned above.
* Open OS Monitor and head to the Misc tab.
* Scroll down to the Network section and find out the IP address of your device and note it down. ( Search under the respective tab : If you are connected to WiFi, it should be under ' wlan0 ' and if you are tethering the internet from your device , then find it under 'ap0' )
* Open QPython and select editor.
Code :
SimpleHTTPServer
from os import chdir
chdir('/system')
SimpleHTTPServer.test()
> chdir is a library that allows you to change directory. So , set it to the path of the folder that you want to access on your computer . If you were access a sub-folder inside the SD card , you could put it as chdir('/sdcard/') .
If you have root access in your device , you might as well access system files too.
(eg : chdir('/') gives the files in the file system ).
* Now save this file in the desired location.
* Click on the run button.
* The console automatically fires up and runs a server at the default port 8000.
* Minimize the application and fire up a browser on your computer or any device to which you want to transfer the files.
* In the URL bar , type in the IP address that you noted down earlier followed by a ' : ' (colon without quotes) and then type in the port - 8000.
For example ,
your_ip:8000 (192.XXX.XX.XX : 8000 )
* You will be able to see the files listed on your browser. Right click on the file you would want to save and select ' Save link as '. Select the desired location and the file will be downloaded.
Since we have saved the server file , we can access it whenever we want by only having to change the directory inside chdir.
Advantages :
* No cables.
* Files are safe.
* Easy setup
Happy syncing !