Hey there👋, welcome back to my blog. Today, I felt like sharing what every developer might come across one day.
You might want to share heavy files or access a file from another computer and one of the ways is to use Bluetooth which is time-consuming and a hectic process that requires setting up or configuring devices.
What if I told you that you could easily share files and directories across computers with just a few lines of Python and as a web developer, there will be a point when you need to create your own local webserver. Python 3 comes embedded with an inbuilt HTTP server
Wait, What is an HTTP Server ❓
An HTTP or web server processes requests via HTTP, a network protocol used to exchange information on the World Wide Web (WWW).
The main function of an HTTP server is to store, process and deliver web pages to clients. Buckle up because we are about to make a local server.
TL;DR 🙂 Watch
How To Share/Send Files ➰:
🚀 First and foremost, make sure you have Python 3
🚀 Make sure that the two computers are on the same wifi or LAN
🚀 Go to the terminal from the folder you want to share &
🚀 Start a server with this command:
py -m http.server
🚀 Open a new terminal
🚀 Copy the address of the
🚀 Paste it in the browser address bar followed by
🚀 The server will be running like this:
🚀 You should see the files in the shared folder
🚀 Now go to the second computer or device:
🚀Open browser and type in the IP address of the first machine, along with port
8000 like this
🚀A page will open showing all the files in the directory being shared from the first computer.
That's it! This is very easy to achieve in Python without having to write any function or code: You gotta fall in love with Python. Fix Firewall issues if you encounter any errors:
Just keep in mind that HTTP.server is only for testing things locally. It usually does only basic security checks and shouldn't be used in production.
If you enjoyed the article, kindly share, like, comment and subscribe for alerts.
Ronnie Atuhaire 😎