Home > Backend Development > Python Tutorial > Python command to start a web server instance

Python command to start a web server instance

高洛峰
Release: 2017-02-27 09:53:46
Original
1933 people have browsed it

Detailed explanation of Python command to start a web server instance

You can create a simple web server using the packages that come with Python. In DOS, cd to the path to be the server root directory and enter the command:

python -m Web server module [port number, default 8000]

For example:

python -m SimpleHTTPServer 8080

Then you can enter

# in the browser ##http://localhost:port number/path


to access server resources.


For example:


http://localhost:8080/index.htm (of course you have to create the index.htm file yourself)


Other machines can also be accessed through the server's IP address.

There are three types of "Web server modules" here:


  1. BaseHTTPServer: Provides basic Web services and processor classes, namely HTTPServer and BaseHTTPRequestHandler .

  2. SimpleHTTPServer: Contains the SimpleHTTPRequestHandler class that performs GET and HEAD requests.

  3. CGIHTTPServer: Contains the CGIHTTPRequestHandler class for processing POST requests and executing.

Thank you for reading, I hope it can help you, thank you for your support of this site!

For more articles related to Python commands to start Web server instances, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template