laitimes

Quickly implement file sharing with one line of code

author:The Treasure Chest of the Eternal King

Hello everyone, I am the Eternal King who loves to share!

I have shared with you a very small and practical but powerful LAN artifact webd before:

But sometimes, we only need to temporarily share and transfer a few small files, it is inevitable to forget where the software is placed, or need to use under others such as Linux, Macos and need to carry out a series of configurations, it feels still a little inconvenient.

Quickly implement file sharing with one line of code
Today I'm going to share another, easier and faster way to do this with a single line of code as long as you have Python installed on your computer.

File sharing

1. Make sure python is installed on the computer and set global variables.

2. Open the cmd command line terminal and enter the folder you need to share:

Quickly implement file sharing with one line of code

3. Enter the following line of magic code:

python -m http.server 888
           

This line of code means to share the computer's files over the http protocol, 888 is the port, you can specify it at will (if it can't be used, then randomly replace the other one).

If the following interface appears, the sharing is successful:

Quickly implement file sharing with one line of code

Access files

1. For this machine, if you can open the browser, enter any of the following URLs in the address bar to test:

http://localhost:888
http://127.0.0.1:888
           

Interface after access:

Quickly implement file sharing with one line of code

2, for other machines connected to the same network, just need to access the link with your IP address on the browser to access the folder, as follows:

Locate the ip address of the native unit in the cmd terminal,

Quickly implement file sharing with one line of code

The address of this computer LAN of Eternity Jun is 192.168.0.107

Enter it in the browser of the other computer

http://192.168.0.107:888/
           

The effect seen is the same as above. Click on the file to view and download it.

Quickly implement file sharing with one line of code

brief summary

Isn't this one-line code for Python file sharing convenient?

Basically, the current Linux and Macos systems will come with Python by default, and friends who use these systems are still very convenient. The next time there is such a scene, can I install X?

If it is a Windows system, and python is not commonly used, it feels like using webd to facilitate some ha ~

Read on