這篇文章主要介紹了python創(chuàng)建一個(gè)最簡(jiǎn)單http webserver服務(wù)器的方法,實(shí)例分析了Python操作http創(chuàng)建服務(wù)器端的相關(guān)技巧,需要的朋友可以參考下
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
Handler = SimpleHTTPRequestHandler
Server = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
Handler.protocol_version = Protocol
httpd = Server(server_address, Handler)
print("Serving HTTP")
httpd.serve_forever()
希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。
更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄