Building and running of Python Web simple server
Python 3 server Building is configured with environment variables, in DOS CD to the project directory, input: python-m http.server--cgi 8080
The following are the problems and solutions I have encountered during the construction process:
1, according to Http://www.cnblogs.com/xuxn/archive/2011/02/14/build-simple-web-server-with-python.html, the establishment of a simple Web server, specific as follows:
A simple Web server can be built with Python's own packages. In DOS CD to the path ready to do the server root directory, enter the command: PYTHON-M Web server module [port number, default 8000] For example:
Python-m simplehttpserver 8080
You can then enter the http://localhost: Port number/path in the browser to access the server resource.
For example:
Http://localhost:8080/index.htm (of course index.htm files have to be created by themselves) other machines can also be accessed through the server's IP address.
The Web server module here has the following three kinds: Basehttpserver: Provide basic Web services and processor classes, respectively, Httpserver and Basehttprequesthandler. Simplehttpserver: Contains Simplehttprequesthandler classes that perform get and head requests. Cgihttpserver: Includes processing post requests and executing Cgihttprequesthandler classes.
2, following the operation of the problem: ' Python ' is not an internal or external command this is because the environment variable is not configured, as follows: The computer-Right click-Property, and then in the left column to find advanced system settings-environment variables, in the system variable to find path, And then add your path to installing Python, for example, I was appended at the back:;D: \python33
3, according to the above operation and then appear: No module named Cgihttpserver appears this reason is mainly described above the method of establishing the server is for Python 2x, according to Http://my.oschina.net/hevakelcj/blog Mentioned in the/373830:
In the Python2.6 version, the/usr/bin/lib/python2.6/directory will have basehttpserver.py, simplehttpserver.py, cgihttpserver.py
But in the Python3.4, there is no above 3 files, but close to the/usr/bin/python3.4/http/server.py file.
In python2.6 the CGI service command is: Python-mcgihttpserver 8080 in python3.4: python3.4-m http/server--cgi 8080
The port number is an optional parameter.
4, do not know whether the above content to write a problem or because my Python version is 3.3.5, so use the above command will report No module Namedhttp/server, modified as follows
Python-m http.server--cgi 8080
5, at run time to copy the program to prepare to do the server root directory