Simple set up a local server file download Python SimpleHTTPServer

Set up FTP, or build a network file system, these methods are able to achieve the shared directory of Linux. But FTP and Network File System functions are too strong, so they have some place is not convenient enough. For example, you want to quickly share a directory on a Linux system to the entire project team would like to do it in a minute, how do?

Very simple to use SimpleHTTPServer.

Various Linux distributions usually have built-in Python, so the use of this method is very convenient. This method is also effective in other OS (such as Windows), but will take some work, you must first set up the Python environment.

SimpleHTTPServer is a module that comes with Python 2, Python is a Web server. It has been incorporated into the Python 3 http.server module. In use SimpleHTTPServer Python 3 was similar to (python3 -m http.server 6789) in the use of Python 2, Python 2 Case paper.

SimpleHTTPServer have a characteristic, if there is to be shared index.html under the directory, then the index.html file will be treated as the default home page; if index.html file does not exist, it will display the entire directory listing.

SimpleHTTPServer use

1) into the shared directory to be
  2) Run python -m SimpleHTTPServer port number
    Note: Do not fill the port number to use port 8000 by default.
  3) the address to access the host browser: HTTP: // IP : port number /

# cd /home/abc # python -m SimpleHTTPServer 8000 Serving HTTP on 0.0.0.0 port 8000 ... 192.168.20.33 - - [09/Jan/2016 15:13:28] "GET / HTTP/1.1" 200 - 192.168.20.33 - - [09/Jan/2016 15:13:33] code 404, message File not found 192.168.20.33 - - [09/Jan/2016 15:13:38] "GET /favicon.ico HTTP/1.1" 404 - 192.168.20.33 - - [09/Jan/2016 15:13:54] "GET /jdk-7u79-linux-x64.tar.gz HTTP/1.1" 200 -

Reproduced in: https: //www.jianshu.com/p/93a1a3932391

Guess you like

Origin blog.csdn.net/weixin_33845477/article/details/91112023