3 votes
Accepted

pset7 index.html, adding buy/sell button which linked to stock respectively

You can send data back to application.py with a GET method. url_for takes arguments that are sent as a query string. From the flask doc: flask.url_for(endpoint, **values) Generates a URL to the given ...
user avatar
3 votes
Accepted

pset7, cash on index.html sometimes giving many decimals (eg.4882.139999999999)

Review the helpers.py section of the spec to remember there is a function supplied that will format floats. Last in the file is usd, a short function that simply formats a float as USD (e.g., 1234....
user avatar
2 votes
Accepted

How to pre-populate sell() and buy() forms from index - Pset7

The "something like" syntax in this call for the href attribute was wrong and has been corrected. It is more something like href="{{ url_for('buy', symbol=stock.symbol ) }}". stock....
user avatar
2 votes

Pset7 - Finance: Cannot figure out how to loop through values in list/dict in order to display results in rows in html table

What is going to be stored into your holdings value is "A list of dictionaries", where each list item will be one stock. i.e each list item will correspond to each row of your query: "SELECT stock, ...
user avatar
  • 123
1 vote
Accepted

Blocked on C$50 Finance suggested personal touch feature - adapting index page to enable transactions in situ

The proximate cause of the error is id is not submitted with the form. There may be an easier way that would eliminate the code that is presumably duplicated between index and buy/sell. The button ...
user avatar
1 vote
Accepted

Finance - Error with Index

--AFTER EDIT-- This line change = lookup(stocks) is a problem. execute returns a list of dictionaries, therefore stocks is a dictionary, therefore lookup is choking, I mean, producing the error ...
user avatar
1 vote
Accepted

html and CSS link do not work Homepage Problem

The problem is because of the trailing slash (/) in the href attributes, for example href="a.html/". There are two places you can see feedback that will describe what it is doing. One is the address ...
user avatar
1 vote
Accepted

Does CS50 IDE run SSI?

SSI is not standard, so if the code does not work, the server may not support it, or the syntax is not adequate. It is not possible what you intend only with HTML or CSS, it is necessary to use some ...
user avatar
  • 5,172
1 vote
Accepted

PSET7 using jinja and binding variables to output in to HTML

The template does not know what stockHeader or portfolioRows is. You'd have to pass it like return render_template("index.html", stockHeader=stockHeader, portfolioRows=portfolioRows). First ...
user avatar
  • 20.7k
1 vote
Accepted

PSET6 Similarities Web Form Errors "Cannot POST /compare" and no CSS

You're browsing templates, not pages generated from templates. You need to call flask run in your similarities directory, and point your browser to the URL flask will present. Something like cd ~/...
user avatar
  • 20.7k
1 vote

How to disable a table (portfolio) in index.html?

{% block main %} {% if empty == "False" %} // TODO Somethig <p>NOOO</p> {% endif %} {% endblock %} Easy fix I was trying to to pass a variable empty as a ...
user avatar
1 vote

How to display python list in index.html ? finance - index.html

Solution {% for stock in stocks %} <tr> <td> {{ stock.symbol }} </td> <td> {{ stock.name }} </td> <td> {{ stock....
user avatar
1 vote
Accepted

How to iterate through different shares in jinja to create the table in index.html

I was tripped out by a similar problem for quite some time before I actually figured out something that worked for me. In my case, what I did is I declared an empty list of rows and initialized an ...
user avatar
  • 40
1 vote

CS50 Pset7: rows inside the for loop are not showing up in index.html

There is no stocks array being sent return render_template("index.html", cash=str(round(cash[0]["cash"], 2)), total_worth=total_asset). Therefore, stocks is an empty array in the html. Therefore {% ...
user avatar
1 vote
Accepted

CS50 Pset7: rows inside the for loop are not showing up in index.html

Try using the dot operator instead. {{stock.stock}} and{{stock.total_shares}}
user avatar
1 vote
Accepted

CS50 Pset7: rows inside the for loop aren't showing up in index.html

lookup() in helpers.py is not available to jinja. It should be called in index. But that would give a big fat exception. Suspect index is sending an empty list to stocks argument.
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible