Python自带http.server模块,可以快速开启一个简易的Web服务器~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
class GetHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
logging.error(self.headers)
http.server.SimpleHTTPRequestHandler.do_GET(self)
def openServer(ip):
#http.server.SimpleHTTPRequestHandler
Handler = GetHandler
socketserver.TCPServer.allow_reuse_address = True
#ip
httpd = socketserver.ThreadingTCPServer(('', PORT), Handler)
socketserver.timeout = 60
socketserver.request_queue_size = 200;
print("serving at port ", PORT)
try:
httpd.serve_forever()
except KeyboardInterrupt:
print ('中断')
finally:
print ('关闭服务')
httpd.server_close()
|
附件部分有脚本代码。脚本代码包含二维码生成,所以需要安装插件:
1
2
3
|
python -m pip install --upgrade pip
pip install qrcode
pip install image
|
附件
server.py