Python SimpleHTTPServer module usage and usage introduction,

Source: Internet
Author: User

Python SimpleHTTPServer module usage and usage introduction,

To build an FTP or a network file system, these methods can achieve directory sharing in Linux. However, FTP and network file systems are too powerful, so they all have some disadvantages. For example, if you want to quickly share a directory of the Linux system to the entire project team and want to do so within one minute, what should you do?

Easy to useSimpleHTTPServer.

Various Linux distributions usually have built-in Python, so this method is very convenient. This method is also effective in other operating systems (such as Windows), but it is troublesome. You must first build a Python environment.

SimpleHTTPServer is a built-in module of Python 2 and a Web server of Python. It has been merged into the http. server Module in Python 3. SimpleHTTPServer's usage in Python 3 is similar to that in Python 2 (python3-m http. server 6789). This document uses Python 2 as an example.

Then the entire directory list is displayed.

How to Use SimpleHTTPServer

1) enter the directory to be shared
2) run the python-m SimpleHTTPServer port number.
NOTE: If no port is specified, port 8000 is used by default.
3) the address of the browser accessing the Host: http: // IP: Port Number/

Example: Execute the command

# 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 -

Click jdk-7u79-linux-x64.tar.gz. the download is successful.

Pay attention to the firewall factors of Linux during use.

Summary

The above is all about the usage and usage of Python's SimpleHTTPServer module. I hope it will be helpful to you. If you are interested, you can continue to refer to other related topics on this site. If you have any shortcomings, please leave a message. Thank you for your support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.