拼團(tuán)眾籌商城系統(tǒng)開發(fā)(技術(shù)詳細(xì))丨拼團(tuán)眾籌商城開發(fā)源碼版
Retail is essentially the product of technology empowerment and consumption demand upgrading.Enterprises rely on the Internet to upgrade the whole process of products from production to circulation to sales through various emerging technological means,such as big data analysis and artificial intelligence technology,and restructure the structure and industrial ecosystem of the entire retail industry.Through online service and offline experience,a new retail model is integrated. web_server.py import socket from sys import argv import gevent from gevent import monkey import time import random import re #服務(wù)器類 class WISG(object):開發(fā)分析I35案例7O98設(shè)計(jì)O7I8? def __init__(self,port,app): self.port=port self.root_dir="./HTML" #創(chuàng)建主套接字 self.server_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #允許端口重用 self.server_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) #主套接字綁定端口 self.server_socket.bind(("",self.port)) #主套接字轉(zhuǎn)為被動(dòng)模式,設(shè)計(jì)方案:MrsFu123 self.server_socket.listen(128) #獲取web框架中的函數(shù)引用 self.app=app pass #啟動(dòng)服務(wù)器對象的入口函數(shù) def run_forever(self): self.create_new_socket() pass #創(chuàng)建新的套接字,使用gevent,使新的套接字以消耗少量資源的協(xié)程方式運(yùn)行 def create_new_socket(self): while True: new_client_socket,new_client_socket_addr=self.server_socket.accept() gevent.spawn(self.deal_accept_data,new_client_socket) #處理接收到的數(shù)據(jù) def deal_accept_data(self,new_client_socket): recv_data=new_client_socket.recv(1024) #接收到的請求為utf-8格式,解析數(shù)據(jù) recv_data=recv_data.decode("utf-8") #如果收到客戶端發(fā)送的空字符,則關(guān)閉連接 if not recv_data: return #將接收到的數(shù)據(jù)轉(zhuǎn)換為列表 recv_data_list=recv_data.splitlines() #獲取請求頭信息 the_request_header=recv_data_list[0] file_name=self.get_file_name(the_request_header) if file_name.endswith(".html"): print("請求的文件名為%s"%(file_name)) #向客戶端發(fā)送文件 self.send_html(file_name,new_client_socket) new_client_socket.close() else: