使用python3的http.server模块要注意的问题

  • Post author:
  • Post category:python



在学习python的web开发时,首先使用了python3中内建的HTTP servers。


使用如下代码:


from http.server import HTTPServer, CGIHTTPRequestHandler

port = 8080

httpd = HTTPServer(('', port), CGIHTTPRequestHandler)
print("Starting simple_httpd on port: " + str(httpd.server_port))
httpd.serve_forever()


创建一个web服务器文件

simple_httpd.py

,在终端上运行该文件:





版权声明:本文为u013687821原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。