Exemple #1
0
def index():
    # This method generates a random identifier and stores it in Flask's session object
    # For any request coming from the client, we'll check it. This way, we avoid
    # CSRF attacks (check https://en.wikipedia.org/wiki/Cross-site_request_forgery )
    session['csrf'] = weblab.create_token()

    return render_template("index.html")
Exemple #2
0
def start(client_data, server_data):
    print("************************************************************************")
    print("Preparing laboratory for user {}...".format(weblab_user.username))
    print()
    print(" - Typically, here you prepare resources.")
    print(" - Since this method is run *before* the user goes to the lab, you can't")
    print("   store information on Flask's 'session'. But you can store it on:")
    print("   weblab_user.data")
    weblab_user.data['local_identifier'] = weblab.create_token()
    print("   In this case: {}".format(weblab_user.data['local_identifier']))
    print()
    print("************************************************************************")

    for light in range(LIGHTS):
        redis.set('hardware:lights:{}'.format(light), 'off')
    redis.set('hardware:microcontroller:state', 'empty')
    redis.delete('hardware:microcontroller:programming')