Python command to enable http. server, pythonhttp. server

Source: Internet
Author: User

Python command to enable http. server, pythonhttp. server

If you want to use the command E: \ zpic as the download directory, then cd in cmd to this directory and execute the command:
Python-m SimpleHTTPServer

The default port number is 8000. the root directory of the server is the working directory for running python commands.

If an error is prompted:
No module named SimpleHTTPServer

 

Try the following command:

Python-m http. server

Use http: // 127.0.0.1: 8000 to access contents in the directory.

 

Or add the port number:Python-m http. server 80

Use http: // 127.0.0.1 to access contents in the directory

 

Disable the server:
1) dos
Enter "ctrl + C" in the running interface to stop
2) python script
Port listening and related python processes need to be stopped

Def stop_server (server) server. sorket. close ()

======================================

The following three modules are used to build an http server:
1) BaseHTTPServer: provides basic Web services and processor classes, including HTTPServer and BaseHTTPRequestHandler;
2) SimpleHTTPServer: contains the SimpleHTTPRequestHandler class that executes GET and HEAD requests;
3) CGIHTTPServer: contains the CGIHTTPRequestHandler class for processing POST requests and execution.

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.