re_password = request.form['re_password'] pw_hash = bcrypt.generate_password_hash(password) validation(cursor, connect, name, login, password, re_password, pw_hash) elif request.form['submit'] == 'Login': cursor.execute("SELECT password FROM users WHERE login='******'") user_data = cursor.fetchall() if not user_data: error = 'Invalid login. Try again.' elif not bcrypt.check_password_hash(user_data[0][0], password): error = 'Invalid login/password. Try again.' else: session['user'] = login return redirect(url_for('players')) return render_template('login.html', error=error) @app.route('/quatro/logout') def logout(): session.pop('user', None) return redirect(url_for('quatro')) @app.route('/quatro/rules') def rules(): return render_template('rules.html') if __name__ == "__main__": app.run()
#!flask/bin/python from game import app app.run(host="127.0.0.1", port=5055, debug=True)
leaders['first'], leaders['second'], leaders[ 'third'] = players_and_items[:3] players_and_items = players_and_items[3:] return render_template('leaderboard.html', players=players_and_items, leaders=leaders) def logged_in_and_auth(id_to_check): id_to_check = str(id_to_check) if session['user_id'] == id_to_check and session['logged_in']: return True else: return False def connect_to_db(app): app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL'] app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.app = app db.init_app(app) if __name__ == '__main__': from game import app connect_to_db(app) app.debug = False # Debug Toolbar! #DebugToolbarExtension(app) app.run(port=5000, host='0.0.0.0')
from game import app # Runs in debug mode if the .py file is called directly if __name__ == '__main__': app.run(host="0.0.0.0", debug=True, threaded=True)
from game import app if __name__ == '__main__': app.run(debug=app.config["DEBUG"])