Skip to content

Instantly share code, notes, and snippets.

@luistung
Created July 29, 2014 08:54
Show Gist options
  • Save luistung/8e769bd9fd22b9a02408 to your computer and use it in GitHub Desktop.
Save luistung/8e769bd9fd22b9a02408 to your computer and use it in GitHub Desktop.
python简单http服务器
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
class TestHTTPHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.protocal_version = 'HTTP/1.1'
self.send_response(200)
self.send_header("Welcome", "Contect")
self.end_headers()
self.wfile.write('hello world')
http_server = HTTPServer(('0.0.0.0', 7778), TestHTTPHandler)
http_server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment