IDE:Pycharm
sever.py
[python] view plain copy
#!/bin/python
#-- coding: UTF-8 --
#文件名:server.py
#create by wzh 2017/10/26
import socket #导入socket模块
import re
from multiprocessing import Process #导入进程模块
福利:私信回复【01】可免费获取python入门教程视频
#设置静态文件根目录
HTML_ROOT_DIR=’./html’
def handle_client(client_socket):
“”“处理客户端连接请求”""
request_data=client_socket.recv(1024)
print(request_data)
request_lines=request_data.splitlines()
for line in request_lines:
print(line)
#‘GET / HTTP/1.1’
request_start_line=request_lines[0].decode(“utf-8”)
print("*"*10)
print(request_start_line)
#提取用户请求的文件名
file_name=re.match(r"\w+ +(/[^ ]*) ",str(request_start_line)).group(1)
if “/” =