0

What mistake am I doing for the below "sell" code:

@app.route("/sell", methods=["GET", "POST"])
@login_required
def sell():
    """Sell shares of stock"""
    if request.method == "GET":
        return render_template("sell.html")

    elif request.method == "POST":
        symbol = db.execute("SELECT stocks_owned FROM Purchase WHERE stocks_owned = ? AND person_id = ?", request.form.get("symbol"),session["user_id"])
        search = lookup(symbol)
        current_value = search["price"]
        shares = db.execute("SELECT share_amount FROM Purchase WHERE share_amount = ? AND person_id = ?", request.form.get("shares"),session["user_id"])
        shares_entered = shares[0]["share_amount"]

        # if the user fails to select a stock or if (somehow, once submitted) the user does not own any shares of that stock.
        if not symbol or not shares:
            return apology("No shares of the stock or insufficient shares to sell", 403)

        else:
            cash = db.execute("SELECT remaining_cash FROM Purchase WHERE person_id = ?", session["user_id"])

            cash += shares_entered * current_value

            db.execute("UPDATE Purchase SET remaining_cash = ? WHERE person_id = ?", cash,session["user_id"])

            db.execute("UPDATE users SET cash = ? WHERE id = ?", cash,session["user_id"])

            past_shares = ("SELECT share_amount FROM Purchase WHERE person_id = ?", session["user_id"])

            current_shares = past_shares - shares_entered

            db.execute("UPDATE Purchase SET share_amount = ? WHERE person_id = ?", current_shares,session["user_id"])

            return redirect("/")

I get the below error for it:

TypeError: quote_from_bytes() expected bytes

You must log in to answer this question.

Browse other questions tagged .