我正在修改从CSGO reddit收到的一些代码,使用刚刚发布的游戏状态集成来实现炸弹计时器,我设法使代码与HTTP Post JSON一起工作,如下所示:import time
import SimpleHTTPServer
import SocketServer
import logging
import cgi
import sys
import json
import signal
PORT = 3000
planted = False
#If we ctrl+C out of python, make sure we close the serial port first
#handler catches and closes it
def signal_handler(signal, frame):
ser.close()
sys.exit(0)
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
#SimpleHTTPServer doesn't handle post by default. Hacked up way to do it here
def do_POST(self):
length = int(self.headers["Content-Length"])
jsonString = str(self.rfile.read(length))
p