MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / WebServerThread

Class WebServerThread

Projects/RemoteCameraRobot/remote_robot.py:64–81  ·  view source on GitHub ↗

Class to make the launch of the flask server non-blocking. Also adds shutdown functionality to it.

Source from the content-addressed store, hash-verified

62app = Flask(__name__, static_url_path='')
63
64class WebServerThread(Thread):
65 '''
66 Class to make the launch of the flask server non-blocking.
67 Also adds shutdown functionality to it.
68 '''
69 def __init__(self, app, host, port):
70 Thread.__init__(self)
71 self.srv = make_server(host, port, app)
72 self.ctx = app.app_context()
73 self.ctx.push()
74
75 def run(self):
76 logging.info('Starting Flask server')
77 self.srv.serve_forever()
78
79 def shutdown(self):
80 logging.info('Stopping Flask server')
81 self.srv.shutdown()
82
83@app.route("/robot", methods = ["POST"])
84def robot_commands():

Callers 1

remote_robot.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected