Exemplo n.º 1
0
def index():
    """Show portfolio of stocks"""
    user_id = session["user_id"]
    # get user data
    user = get_user_details(db, user_id)
    # get user stocks (grouped by symbol - sum of bought stocks - sum of sold stocks by symbol)
    stocks, total_value = get_user_stocks(db, user_id)
    return render_template("index.html", stocks=stocks)
Exemplo n.º 2
0
def get_user_info_post():
    log.info('/get_user_info')
    pretty_print_POST(request)
    response = json.loads(request.data)
    statement_validate = query.get_user_info_validate_user.format(response["userid"])
    log.info("query: {}".format(statement_validate))
    result = db_fetch(statement_validate)
    if len(result) == 0:
        return Response(json.dumps({"error": "user not registered"}), headers=HEADER, status=200, mimetype='application/json')
    if result[0][0] != response["password"]:
        return Response(json.dumps({"error": "password invalid"}), headers=HEADER, status=200, mimetype='application/json')
    user_data = get_user_details(response["userid"])

    return Response(json.dumps(user_data), headers=HEADER, status=200, mimetype='application/json')
Exemplo n.º 3
0
def _check_email_login():
    email = request.form["email"]
    if get_user_details(email) is None:
        return "false"
    else:
        return "true"
Exemplo n.º 4
0
def get_user_info_get():
    log.info('/get_user_info')
    args = request.args.to_dict()["userid"]
    user_data = get_user_details(args)

    return Response(json.dumps(user_data), headers=HEADER, status=200, mimetype='application/json')