Python3 simple to build your own server

Source: Internet
Author: User
This article mainly introduces the simple building of Python3 with the server, has a certain reference value, and now share to everyone, the need for friends can refer to

Web development, we start by building a simple server, Python comes with a service module, and Python3 compared to Python2 is very different,

In the Python2.6 version, the/usr/bin/lib/python2.6/directory will have basehttpserver.py, simplehttpserver.py, cgihttpserver.py two files,

But in the Python3.4, there is no above 3 files, but close to the/usr/bin/python3.4/http/server.py file.

So in the Python2 version, if you want to start a Python-brought service, enter it in the Doc window:

Python-m Cgihttpserver 8081

where 8081 port number can be set by itself, the default port number is 8080

And in Python3, because the

basehttpserver.py, simplehttpserver.py, cgihttpserver.py modules are merged for the server module, so the code to start the server has also changed to:

<strong>python-m Http.server 8081</strong>

After starting correctly, the following:

Enter localhost: port number in the browser to access

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.