Use Python to quickly build a local site

Source: Internet
Author: User

If you need a simple Web Server, but you don't want to download and install the complex HTTP service programs, such as: Apache,iss,nodejs. Well, Python might help you. Use Python to complete a simple built-in HTTP server. As a result, you can display your directories and files in HTTP. The only thing you need to do is install a python (if you're using a Mac system, you've got Python, and the installation is saved).

In fact, this is a very useful way to share files. It is simple to implement a tiny HTTP service program, which requires only one command line under Python. Here is the command line:

Shell Code

1 cd/desktop/website2 python-m simplehttpserver  

That's fine, and our HTTP service listens on port No. 8000. You will get the following information:

Serving HTTP on 0.0.0.0 Port 8000 ...

You can open your browser (ie or chrome) and enter the following URL:

http://127.0.0.1:8000

LAN other users can use the native IP plus 8000 port to access

If your website directory has a file name named Index.html, then the file will become a default page, and if there is no such file, then the directory list will be displayed.

If you want to change the port number, you can use the following command:

Python-m simplehttpserver 8080

Use Python to quickly build a local site

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.