加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
visual_chart_ACP60.py 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
#! /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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化