def load_problems_to_redis(filename, comment="#"):
    problem_database = parseProblemFile(PROBLEM_FILE)
    connection = redis.Redis(connection_pool = problem_pool)
    for name, problem in problem_database:
        connection.set(name, problem)
    connection.set("__initiated__", "True")
示例#2
0
from flask_conf import SECRET_KEY
from log_to_users import log_submission, log_purchase, log_on_market, log_changed_price

from werkzeug.contrib.fixers import ProxyFix

app = Flask(__name__)

app.secret_key = SECRET_KEY
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"

user_pool = redis.ConnectionPool(host=HOSTNAME, port=PORT, db=USER_DB)
problem_pool = redis.ConnectionPool(host=HOSTNAME, port=PORT, db=PROBLEM_DB)

parsed_problem_file = parseProblemFile(PROBLEM_FILE)

app.wsgi_app = ProxyFix(app.wsgi_app)


@login_manager.user_loader
def load_user(user_id):
    result = User.get(user_id)
    if result:
        name, display_name, password_hash = User.user_database[user_id]
        return User(name, display_name, password_hash)
    else:
        return None


@app.route("/login", methods=["GET", "POST"])