Skip to content

Share you files across your local network using python

License

Notifications You must be signed in to change notification settings

DHRUV-CODER/Web-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Topics Covered

Click and go

About

This is a simple Web Server to view/share your file on your local network. You can potentially use this to open a file/folder on your other device without worrying about sending/downloading on the device.

Using this you can save time and all the hassle of sharing is gone.

ezgif-2-7a1f23866be4

Security Risks ?

Don't Run this on a public wifi ie:(starbucks,airport wifi etc..), as other can visit and view the content.

If you want to access only on you hosted device for some reason then remove host=0.0.0.0,

If your running on your personal wifi and only trusted users are connected to your wifi , then no worries . Hakuna Matata

Run using python

  1. Git clone the repo or Download the zip
git clone https://github.com/DHRUV-CODER/Web-Server.git
cd .\Web-Server

For Linux (Requires Python3 to be installed)

pip3 install flask
python3 .\server.py

or on other os

pip install flask
py .\server.py
  1. After Running the server.py

  2. Website will be available on : localhost

Use of m_server.py?

m_server.py is a single version of the server.py , with the code minimized . m_server.py doesn't require the templates folder . So if you want it clean and the work to be done with single file , use m_server.py and feel free to delete the rest of the files & folder

Steps to Download the exe

NOTE: To run the exe on LINUX , give the exe file the permission to run. else it wont run , Can't get it to work CLICK ME FOR A TUTORIAL

Download the latest exe from Here

image

Then put in the Directory that you want to share.

Example : Desktop

image

Open the exe and wait till it is Hosted on port 5000

image

Click allow if you want to use it on other device

image

After that , open your preferred Browser and go to 127.0.0.1:5000 or localhost:5000 , Only visitable on hosted device

There you can see all the files and folders

image

You can click on respective folders and view the content

image

We also support syntax highlighting which makes the content inside more readable, syntax highlighting is available for almost every type of file extension

image

Well these were some of the features .

I want to share it on my local network , how do i visit on other device ?

image

Click allow

image

Note: For you the url might be different And that is your url , now you can use this url to visit on other device

or , if you can't find the url

Well it is pretty simple , Find you hosted device's physical address and put :5000 behind it .

For Eg:

You can open cmd or powershell upto you, and type ipconfig there you can find your hosted device's physical address.

image

In my case it is 192.168.100.3 , so to visit the webserver put port :5000 behind it . Final uri 192.168.100.3:5000

I want to share it publicly to my friends and colleagues ? How do i ?

One way can be port forwarding and stuff . Which is pretty boring and complex.

Instead i suggest you to use a tool like ngrok

What is the use Ngrok?

ngrok allows you to expose a web server running on your local machine to the internet. Just tell ngrok what port your web server is listening on.

Download ngrok

After Downloading , open the folder which it is in using your preferred terminal.

In my case i pasted it in Desktop

image

Then type this command to run ngrok on port 5000

This will expose the port 5000 to the internet

image

and hit Enter

image

Command: ./ngrok http 5000

Copy the url provided by ngrok , now you can share / view it publicly.

Note: As i am using the free version it , this stay online for temporary time period only. I mean 5-6 hrs enough ig , You can always rerun it for new url .

To close it , simply press ctrl+c

Bonus

There is a inbuilt cli command avail with python , which will provide you with web server, it is bit uglier and not that useful for sharing purposes.

Command : python3 -m http.server 5000

You just need python for this.

Conclusion

Well that it for the steps . If you find any typos , feel free to send a pull request.

Hope it helps you.

Credits