Line of Python code to make your computer into a HTTP server to share files with colleagues

If you are in company, organization, need to give your colleagues, how would you do in transferring a file to your own computer? Micro letter, QQ, E-mail, network disk, and so on. Of course, you can use the command scp or ftp, but this is all too much trouble, do not know you as a programmer is not there an alternative idea that he quickly build a simple HTTP server, allowing colleagues to download or upload it?

And should the download speed is quite fast, if you want to change the path for others to access, as long as the structures in the path modify said before it.

Python3 command

python -m http.server 8000

 Description: This port number (8000) can easily define your own, as long as you can not be occupied, it will put the files and directories in the current directory displayed, if we do not specify a port, the default is 8000.

Python2 command

python -m SimpleHTTPServer 8000

Note: When using the command, the browser for the "server IP: 8000", the page file is displayed under Python is the current working directory where the file.

But this command is currently running, not running in the background, that is to say if Ctrl + C, then the port will be shut down.

Results as shown:

Line of Python code to make your computer into a HTTP server to share files with colleagues

Do not phone or other settings can also access the download, of course, need to know the IP address of the machine. Linux command to view the IP address: ifconfig

Then in the browser address bar enter the IP address and port number can be, as shown below:

Line of Python code to make your computer into a HTTP server to share files with colleagues

You can be directly downloaded

Line of Python code to make your computer into a HTTP server to share files with colleagues

Line of Python code to make your computer into a HTTP server to share files with colleagues

If the folder inside the index.html file, that is, open the page.

Line of Python code to make your computer into a HTTP server to share files with colleagues

Or directly open PDF files or download

Line of Python code to make your computer into a HTTP server to share files with colleagues

However However, this can only be downloaded, I want to file on your phone or other device to upload to the server how to do it? Do not worry, there is a large cattle early for us to think it over, look at the following screenshot.

Run this py, now by phone or other device you can upload a file, click Choose File.

Line of Python code to make your computer into a HTTP server to share files with colleagues

Select the file

Line of Python code to make your computer into a HTTP server to share files with colleagues

Uploaded successfully.

Line of Python code to make your computer into a HTTP server to share files with colleagues

Line of Python code to make your computer into a HTTP server to share files with colleagues

Server-side display:

Line of Python code to make your computer into a HTTP server to share files with colleagues

Guess you like

Origin www.linuxidc.com/Linux/2019-11/161480.htm