These three simple steps to build Python http server you would not, right?

Introduction

text and pictures of this article from the network, only to learn, exchange, not for any commercial purposes, belongs to original author, if any questions, please contact us for treatment.

I read a book called think like scientists python simple to understand and the next set up a small server ...

The first step is

The first step - to check whether there is machine where the Python development environment 
Write pictures described here

I developed machine environment is Python 2.6.6 environment in >>> print input character, the other is not very good if you learn, you can go to small series of Python exchange dress: a long time and its military while a stream of thought (Digital under homonym) conversion can be found inside the latest Python tutorial project
Step Two - new folder execute Python scripts

import SimpleHTTPServer
import SocketServer

PORT = 8081

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT httpd.serve_forever()

Figure server executes the script has successfully accessed under the record output 
Write pictures described here

The third step - test whether you can access

Write pictures described here

Such a simple Python build server is complete ...

Guess you like

Origin www.cnblogs.com/chengxuyuanaa/p/11981042.html