windows下python怎么搭建web服务器?

如题所述

python创建一个最简单httpwebserver服务器的方法:importsysimportBaseHTTPServerfromSimpleHTTPServerimportSimpleHTTPRequestHandlerHandler=SimpleHTTPRequestHandlerServer=BaseHTTPServer.HTTPServerProtocol=HTTP/1.0ifsys.argv[1:]:port=int(sys.argv[1])else:port=8000server_address=('127.0.0.1',port)Handler.protocol_version=Protocolhttpd=Server(server_address,Handler)print(ServingHTTP)httpd.serve_forever()

温馨提示:答案为网友推荐,仅供参考
相似回答