You can use the SimpleHTTPServer module that comes with Python to share files. Even though the thought of using Python SimpleHTTPServer may seem complicated it is not. It is so straightforward that you do not need to have any prior knowledge on Python programming.
Using Python SimpleHTTPServer with Mac
Follow the instructions below to work with the Python SimpleHTTPServer:
Sharing the files
Follow the instructions below to share files with a remote user using the Python SimpleHTTPServer:
Step 1: Share the file
- Download the Python script (simpleHTTPServer.py.zip) from here.
- Unzip the simpleHTTPServer.py.zip file.
- Navigate to the directory that has the folders and files that you wish to share.
For example:cd /Users/MH/Documents/APIM_2.5.0/Share-zone
- Copy the simpleHTTPServer.py file to the folder that contains the files that need to be shared.For example:Copy the simpleHTTPServer.py file from the downloads folder to the Share-zone folder, which is the folder that you are going to share.
cp ~/Downloads/simpleHTTPServer.py
- Compress the files that you wish to share.
tar -cvzf <compressed-folder-name>.tar.gz <folder-to-be-copied>/
tar -cvzf apim.tar.gz apim/
- Start the Python simpleHTTPServer.
python simpleHTTPServer.py
MH-MacBook-Air:APIM_2.5.0 MH$ python simpleHTTPServer.py serving at port 8000 10.100.7.36 - - [25/Jun/2018 12:04:54] "GET / HTTP/1.1" 200 - 10.100.7.36 - - [25/Jun/2018 12:04:57] "GET /apim.tar.gz HTTP/1.1" 200 -
Step 2: Share your details with the other party
- Identify your IP address.
You can retrieve your IP address by executing the following command:ifconfig
- Identify the port that the Python simpleHTTPServer is using.
When the Python server starts, the port that it is using will be printed in the terminal.
For example:MH-MacBook-Air:APIM_2.5.0 MH$ python simpleHTTPServer.py serving at port 8000 10.100.7.36 - - [25/Jun/2018 12:04:54] "GET / HTTP/1.1" 200 - 10.100.7.36 - - [25/Jun/2018 12:04:57] "GET /apim.tar.gz HTTP/1.1" 200 -
Share the above details with the other party whom you wish to share the files with.
Retrieving the shared file
- Access the respective serving URL via your browser in order to be able to download the file that is being shared with you.
http://<sender-IP-address>:<serving-port>
http://10.100.0.113:8000
- Click on the compressed file (e.g., apim.tar.gz).
It will get downloaded automatically.
Stopping the server
After the other party has finished copying all the file, navigate to the terminal that the Python simpleHTTPServer is running and press the following keys to stop the server.Ctrl +C
. . .
I hope that this article was useful to you.
Acknowledgements
- Photo by Pixabay
https://pixabay.com/en/ilight-ilightmarine-abstract-2185506/ - HTML code blocks were formatted using hilite.me
Comments
Post a Comment