Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to access the local files externally through ngrok and python HTTP Server?

This tutorial explains how to share or access the local files externally through ngrok and Python Http Server.
I have the below two scenarios
  • a set of files that needs to be shared outside
  • share a simple website externally
The above scenarios can be achieved through Apache Server and external DNS configurations but require more configurations efforts.
  • ngrok free or paid version
  • Python latest version
Let us see how to enable the above scenarios through ngrok and python Http Server with minimal configuration effort.
As a first step download ngrok(ngrok.com) for the required OS and extract the files

ngrok
ngrok

The ngrok allows you to expose a webserver running on your local machine to the internet. Just tell ngrok what port your web server is listening on.
On the free plan, ngrok’s URLs are randomly generated and temporary. If you want to use the same URL every time, you need to upgrade to a paid plan so that you can use the subdomain option for a stable URL. There are different paid plans they will provide some advance features like custom/reserved domains and multiple tunnels etc

ngrok

Python standard library comes with an in-built webserver which can be invoked for simple web client server communication
The required port number can be assigned and the web server is accessed through this port
My system has python version 3.7.0 installed— “py -vi”


In the first scenario, i want to share some regular files externally

share files externally through ngrok and python http server

To start the HTTP server, cd to to the folder that should be shared(C:\Albin\blogData\demo\Share) through command prompt and execute the command “py -m http.server 80” — change the port number as required

share files externally through ngrok and python http server

Now the files are accessible through localhost

share files externally through ngrok and python http server

Let's now start ngrok to share this folder externally, cd to the folder where ngrok was extracted(C:\Albin\SW\ngrok-stable-windows-amd64)
Execute “ngrok.exe http 80”(80 is where python HTTP server running)

share files externally through ngrok and python http server

Now the external requests(http/https) are forwarded to localhost webserver through ngrok proxy domain

share files externally through ngrok and python http server

To access simple website externally, created a index.html file along with some test files into a folder(C:\Albin\blogData\demo\site), cd to the folder where the index.html and other files are located

share files externally through ngrok and python http server

Re-start the HTTP server, the pages are now accessible outside

share files externally through ngrok and python http server

The traffic can be monitored through the following URL — "); text-decoration-line: none;' target="_blank">http://127.0.0.1:4040

share files externally through ngrok and python http server

The ngrok and python HTTP server can be used to share the local files externally without much effort and configurations.


This post first appeared on Albin's, please read the originial post: here

Share the post

How to access the local files externally through ngrok and python HTTP Server?

×

Subscribe to Albin's

Get updates delivered right to your inbox!

Thank you for your subscription

×