How can I make the action loop when it get one data and change action immediately when it get other data?

时间:2018-12-03 13:15:24

标签: python raspberry-pi

This is a webrobot design by rpi, how can I make the action loop when it gets one data from webpage and change actions immediately when it gets other data? For example, if you get data 1, then loop action 1. If you get data 5 when loop action 1, then the action is changed to action 5.

@app.route('/<data>')
def reroute(data):
    Data = int(data)

    if Data == 1:
        driver.turn_left()
    elif Data == 2:
        driver.forward()
    elif Data == 3:
        driver.turn_right()
    elif Data == 4:
        driver.backward()
    elif Data == 5:
        driver.rob_back()
    elif Data == 6:
        driver.rob_power_off()
    elif Data == 7:
        driver.camera_up()
    elif Data == 8:
        driver.camera_down()
    elif Data == 9:
        driver.camera_left()
    elif Data == 10:
        driver.camera_right()
    elif Data == 11:
        driver.camera_pwr_on()
    elif Data == 12:
        driver.rob_pwr_on()

    response = make_response(redirect(url_for('index')))
    return(response)

0 个答案:

没有答案