"title": "Price", "showspikes": True, "spikedash": "dot", "spikemode": "across", "spikesnap": "cursor", } x_axis = { "title": "Time", "showspikes": True, "spikedash": "dot", "spikemode": "across", "spikesnap": "cursor", } user_pwd, user_names = users_info() _app_route = "/" # Create a login route @app.server.route("/login", methods=["POST"]) def route_login(): data = flask.request.form username = data.get("username") password = data.get("password") if username not in user_pwd.keys() or user_pwd[username] != password: return flask.redirect("/login") else:
def route_login(): user_pwd, user_names = users_info() data = flask.request.form username = data.get('username') password = data.get('password') conn = psycopg2.connect(DATABASE_URL, sslmode='require') cur = conn.cursor() cur.execute("SELECT username, password FROM User_info WHERE username = (%s) AND password = crypt(%s, password);", (username, password)) # crypt(%s, gen_salt('bf')) players = cur.fetchall() #print(players) cur.close() conn.close() if len(players) == 0: #if username not in user_pwd.keys() or user_pwd[username] != password: return flask.redirect('/login') else: ############################################################# session_cookie = username user_active = session_cookie conn = psycopg2.connect(DATABASE_URL, sslmode='require') cur = conn.cursor() cur.execute("SELECT days FROM Leader_board WHERE Player = (%s);", (user_active,)) # print(players) days = cur.fetchone() cur.execute("SELECT thermic FROM portfolio WHERE player = (%s);", (session_cookie,)) # print(players) id = cur.fetchone() cur.close() conn.close() # if len(days): if days and id: day = days[0] #print(day) #print(len(app.WF_real_power) / 96) if day >= app.play_days: #len(app.WF_real_power) / 96: rep = flask.redirect('/Page_end') rep.set_cookie('custom-auth-session', username, max_age=7200) # expires in 2 hours return rep # Return a redirect with rep = flask.redirect(_app_route) # Here we just store the given username in a cookie. # Actual session cookies should be signed or use a JWT token. rep.set_cookie('custom-auth-session', username, max_age=7200) # expires in 2 hours return rep ############################################################# elif not days or not id: rep = flask.redirect('/portfolio') rep.set_cookie('custom-auth-session', username, max_age=7200) # expires in 2 hours return rep # Return a redirect with rep = flask.redirect(_app_route) # Here we just store the given username in a cookie. # Actual session cookies should be signed or use a JWT token. rep.set_cookie('custom-auth-session', username, max_age=7200) # expires in 2 hours return rep