Pset7 index. I’m getting raise TypeError("quote_from_bytes() expected bytes") TypeError: quote_from_bytes() expected bytes.

I tried several times to rewrite the code but I always come across this error which I have no idea how to get rid of. Please, help.

This is my python https://pastebin.com/WW2wNQXz

This is my jinja https://pastebin.com/KBCQKnwz

  • do u get this error while running ur flask application?
    – sk.76
    Commented Oct 21, 2018 at 8:56
  • I get 500 Internal Server Error. Commented Oct 21, 2018 at 8:59

1 Answer 1


There are few lines of code you may consider editing and removing.It suffices to pass the entire rows of the user rather than selecting individual columns and there is no form for index route and you should pass the rows as key value pairs to the index.html as below :

def index():
"""Show portfolio of stocks"""

rows = db.execute("SELECT * FROM portfolio WHERE id = :id", id = session["user_id"])

return render_template("index.html", ROWS=rows)

Jinja :

{% block main %}

<table class="table table-striped">
     {% for row in ROWS %}
     {% endfor %}

<% endblock %}
  • does this help?
    – sk.76
    Commented Oct 21, 2018 at 9:18
  • What if I’m selecting information from 2 tables and a lookup. How do I organise jinja in this case? I get that in Python in return I can just do symbol=symbol, portfolio =portfolio, cash=users[0][‘cash’]. Commented Oct 21, 2018 at 9:22
  • I see that you have used lookup with request.form.get("symbol") , is there any form submission in index.html because this is using the default get method?
    – sk.76
    Commented Oct 21, 2018 at 9:27
  • I just use symbol[‘symbol’]. Is that what you are asking? Commented Oct 21, 2018 at 9:32
  • No, I mean symbol = lookup(request.form.get("symbol"))
    – sk.76
    Commented Oct 21, 2018 at 9:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .