How to create a web server in Android Mobile ?
You may be a web developer and might have created many web pages using Html, css , js , php, sql etc.. but you might be worried about seeing the demo of your webpage , in Computer youll easily see the demo but in mobile its tedious process even in Computer system you cant see the live demo , if youre developing software in someother language there is an compiler but for web languages like Html, css and other languages there is no special compiler the compiler or to see the output you mist use your browser only so today we are going to see how to see the live demo of our website in our browser.
Requirements :
1) Termux application - Download here
2) your web files
3) Python and ngrok installed
After downloading the Termux application type these commands to get started , Termux is an Linux environment based Mobile application so we can use Linux commands in that
Step 1 : First step is update and upgrade
pkg update && pkg upgrade
Step 2 : Go to ngrok.com and create account and see the steps to download
You can see the steps like this and there will be an auth token for your account to link then after installing place your web files in any folder and copy its position
After copying the location of the folder in which the web files present open the termux application now and do the following
Step 3 : In Termux type the cd and the copied path of the folder in which the web files present
Then press enter , you will be navigated to the directory in which your web files present then press 'ls' command to check the files are present
Step 4 : Now you can create your local server on the current directory by using a python command
" python3 -m http.server (any port)"
The port number must be within range of
1024 - 65535 , after adding any port number you can press Enter to start the local server to check the server is running you can go to your browser and type
" localhost:8000 "
After typing this in browser if you see your website then you can confirm that its running now come to termux and port forward the port in which our website is running.
Step 5 : Now we can use ngrok command in new session
After typing the given command press enter you can see the ngrok has been started and it gives you two temp domains with http and https protocal
Yeah !!! We can see our Website is Running in that domain , this is not only for local machine you can send this URL to anyone and you can show them your website even and one main thing is the Termux session must be active otherwise you cant get the Website it will show error.
Yeah we have seen how to create a simple web server in mobile and how to host a simple website for temporary time hope you enjoyed !
1 Comments
🔥🔥👌
ReplyDelete