Hi guys.
In this post I will show you how to run an http server on an Android device.
I am going to use python's http server for this purpose.
So you need to get python in your Android phone. Inorder to install python you need to have a terminal emulator application installed. So install a terminal emulator application from the play store. I am using Termux. Termux is available on the play store.
Install Termux and run it.
Termux terminal window looks like this.
Now install python by entering following command
pkg install python
The above command will install python 3.
You can check python version using the following command.
python --version
Now it's time to start the http server on port 8000
If you are having python 3.x then run the following command
python -m http.server 8000
If you are having python version 2.x then run the following command
python -m SimpleHTTPServer 8000
And that's it. You have successfully started the http server on port 8000.
You can verify this by opening your favorite browser and go to http://localhost:8000
If it is working. Then the browser will show the file list of the current directory.
To stop the server go to Termux and press and hold volume down button and press C on keypad. Volume down work as Ctrl key.
The current folder you are in will be the root folder. You can change the directory using cd command and then start server in it.
For example
cd /sdcard/myprograms
python -m http.server 8000
This will run the http server on localhost port 8000 as /sdcard/myprograms as root directory.
In this post I will show you how to run an http server on an Android device.
I am going to use python's http server for this purpose.
So you need to get python in your Android phone. Inorder to install python you need to have a terminal emulator application installed. So install a terminal emulator application from the play store. I am using Termux. Termux is available on the play store.
Install Termux and run it.
Termux terminal window looks like this.
Now install python by entering following command
pkg install python
![]() |
| Python getting updated since it is already installed. |
The above command will install python 3.
You can check python version using the following command.
python --version
Now it's time to start the http server on port 8000
If you are having python 3.x then run the following command
python -m http.server 8000
If you are having python version 2.x then run the following command
python -m SimpleHTTPServer 8000
And that's it. You have successfully started the http server on port 8000.
You can verify this by opening your favorite browser and go to http://localhost:8000
If it is working. Then the browser will show the file list of the current directory.
To stop the server go to Termux and press and hold volume down button and press C on keypad. Volume down work as Ctrl key.
The current folder you are in will be the root folder. You can change the directory using cd command and then start server in it.
For example
cd /sdcard/myprograms
python -m http.server 8000
This will run the http server on localhost port 8000 as /sdcard/myprograms as root directory.






Comments
Post a Comment