We changed our privacy policy. Read more.
3

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 endpoint with the method provided. Variable arguments that are unknown to the target endpoint are appended to the generated URL as query arguments. So ...


3

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.56 is formatted as $1,234.56)


2

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.symbol should not be quoted nor escaped with braces. (the quotes make it a literal; the braces are only used to escape the objects from html). An a element ...


2

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, shares FROM portfolio WHERE id = :id" Now iterating over a simple list of fruits ( eg: fruits = ['apples', 'oranges', 'pears', 'apricots'] ) can be done simply ...


1

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 element has an attribute formaction that will override the action attribute of the form element.


1

--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 message. This line shares= float(change["shares"]) is a problem, since lookup does not return a key named "shares". I can't say for sure if that ...


1

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 bar in the browser, notice on the second click it will look something like http://ec2-......amazonaws.com:8080/b.html/a.html/. You can also look at the server ...


1

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 programming language suitable for the case such as PHP. The most "easy" is to use a framework like flask (with python) that allows you to do this easily through ...


1

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 portfolioRows determines the name in the template, second portfolioRows is evaluated in the Python script and determines the value passed. Think of it as name=value, in ...


1

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 ~/workspace/pset6/similarities flask run (path might be different, and server is stopped via Ctrl+C) Umm... you're using the IDE50, right? Flask might require ...


1

{% 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 parameter with value to index.html, where it was checked {% if {{ empty }} == "False" %}` The idea is good, but it did not work. Apparently instead of {% if {{ ...


1

Solution {% for stock in stocks %} <tr> <td> {{ stock.symbol }} </td> <td> {{ stock.name }} </td> <td> {{ stock.quantity }} </td> <td> {{ stock.price }} </td> </tr> {% endfor %}


1

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 index variable to 0. Then I assigned my SELECT statement to another variable (ex.: data). Then in the for loop in application.py I constructed each row by ...


1

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 {% for stock in stocks %} executes 0 times.


1

Try using the dot operator instead. {{stock.stock}} and{{stock.total_shares}}


1

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.


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