如何使用WebSocket将HTML消息发送到Python Server

时间:2019-05-16 07:41:08

标签: python html websocket

编写程序以在HTML和Python Server之间进行通信。建立了连接,但服务器端未显示我以HTML(字符串格式)编写的通信消息。

我尝试过Python服务器程序,websockets和html编程

'''使用python的服务器端程序'''

IF OBJECT_ID('#Temp') IS NOT NULL DROP TABLE #Temp

CREATE TABLE #Temp
(
    Col1 Type1,
    Col2 Type2
)

INSERT INTO #Temp EXEC [dbo].[Procedure_Name]

SELECT * FROM #Temp

'''html代码'''

 def RcvDatafromUI(self):
        while True:
            json_data = self.conn.recv(1024)
            try:
                if json_data == b'\r\n' or b'':
                    print("Looping Again")
                    continue
                else:
                    print("RcvdDAta : ", json_data)
                    json_string = json_data.decode('utf-8')
                    print("DecodedDAta : ", json_string)
                    #print('type decode=',type(json_string))
                    json_dict = json.loads(ast.literal_eval(json_string))
                    print('json_dict=', json_dict)
                    y = parsejsondata.ParseJson(json_dict)
                    if y == "Success":
                        PloverMain.SendDAtatoUI('{"Command":"Start 
                             ","Status":"Success/Fail"}')
                PloverMain.RcvDatafromUI()

0 个答案:

没有答案
相关问题