moved socket.emit to the live_request function

This commit is contained in:
Hannes Klinckaert 2019-10-02 13:12:08 +02:00
parent c89fba9594
commit f226a4e51a

View file

@ -53,12 +53,13 @@ def start_run(run_index):
@app.route("/link/start/<run>/<link_index>")
def link_start(run, link_index):
request_data = live_request(run, link_index, f'/link/start/{run}/{link_index}') #make request show up on the live requests
if not run.isdigit() or not link_index.isdigit():
return f'{run} and/or {link_index} is not a number'
start = time()
request_data = live_request(run, link_index)
sio.emit('live_request', request_data)
if db["current_run"] != run:
response = "Wrong run number, check that you update your run", 404
@ -100,12 +101,14 @@ def connect(sid, data):
sio.emit('sync_current_run', current_run, room=sid)
def live_request(run, index):
def live_request(run, index, route_data):
ip = request.remote_addr
request_data = {}
request_data["hostname"] = lookup_hostname(ip)
request_data["time"] = time()
return request_data
request_data["route"] = route_data
sio.emit('live_request', request_data)
@lru_cache()