0

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

2
  • do u get this error while running ur flask application? – sk.76 Oct 21 '18 at 8:56
  • I get 500 Internal Server Error. – IrinaPenzina Oct 21 '18 at 8:59
0

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">
        <tr>
            <th>Symbol</th>
            <th>Name</th>
            <th>Shares</th>
            <th>Price</th>
            <th>Total</th>
        </tr>
     {% for row in ROWS %}
     <tr>
         <td>{{row.symbol}}</td>
         <td>{{row.name}}</td>
         <td>{{row.shares}}</td>
         <td>{{row.price}}</td>
         <td>{{row.stock}}</td>
     </tr>
     {% endfor %}

 </table>
<% endblock %}
16
  • does this help? – sk.76 Oct 21 '18 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’]. – IrinaPenzina Oct 21 '18 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 Oct 21 '18 at 9:27
  • I just use symbol[‘symbol’]. Is that what you are asking? – IrinaPenzina Oct 21 '18 at 9:32
  • No, I mean symbol = lookup(request.form.get("symbol")) – sk.76 Oct 21 '18 at 9:34

You must log in to answer this question.

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