代码拉取完成,页面将自动刷新
#! /usr/bin/env python3
# -*- coding: UTF-8 -*-
# Author: Bary Chen
import socket
import threading
import time
import httplib2
from tools import qt
# todo 增加ACP60的检测
def handle_client(client_socket:socket.socket):
"""
处理客户端请求
"""
request_data = client_socket.recv(1024)
print("request data:", request_data)
# 构造响应数据
# response_start_line = "HTTP/1.1 200 OK\r\n"
# response_headers = "Server: My server\r\n"
# response_body = "<h1>Python HTTP Test</h1>"
# response = (response_start_line + response_headers + "\r\n" + response_body).encode()
response = "HTTP/1.1 200 OK\r\n\r\nkkkkk"
# 向客户端返回响应数据
client_socket.send(response.encode('utf-8'))
# # 关闭客户端连接
# time.sleep(0.1)
client_socket.close()
if __name__ == '__main__':
# import re
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind(('127.0.0.1', 8810))
server_socket.listen(1)
while True:
client_socket, client_address = server_socket.accept()
# print(type(client_socket))
client_socket.settimeout(0.2)
threading.Thread(target=handle_client, args=(client_socket,)).start()
# t.join()
# client_socket.close()
# handle_client(client_socket)
pass
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。