[Python] python创建一个最简单的http webserver服务器 →→→→→进入此内容的聊天室

来自 , 2019-06-27, 写在 Python, 查看 108 次.
URL http://www.code666.cn/view/5f0453f7
  1. import sys
  2. import BaseHTTPServer
  3. from SimpleHTTPServer import SimpleHTTPRequestHandler
  4.  
  5. Handler = SimpleHTTPRequestHandler
  6. Server = BaseHTTPServer.HTTPServer
  7. Protocol = "HTTP/1.0"
  8.  
  9. if sys.argv[1:]:
  10.    port = int(sys.argv[1])
  11. else:
  12.    port = 8000
  13.  
  14. server_address = ('127.0.0.1', port)
  15.  
  16. Handler.protocol_version = Protocol
  17. httpd = Server(server_address, Handler)
  18.  
  19. print("Serving HTTP")
  20. httpd.serve_forever()
  21.  
  22. #//python/7381

回复 "python创建一个最简单的http webserver服务器"

这儿你可以回复上面这条便签

captcha