Skip to main content
Edit: added html code for clarity.
Source Link

I have the latest (I think) distribution code and I have exported the API key. Here is my code and it keeps returning 'None'. I can't figure out why I can't look up a stock quote. Do I need to change the helper.py function for lookup? Because I assumed that was already written fully.

@app.route("/quote", methods=["GET", "POST"])
@login_required
def quote():
    """Get stock quote."""
    if request.method == "GET":
        return render_template("quote.html")
    else:
        # lookup symbol that was submitted
        if not request.form.get("stock"):
            return apology("must provide stock symbol")
        else:
            symbol = request.form.get("stock")
            quote = lookup(symbol)
            if quote != None:
                return render_template("quoted.html", quote=quote)
            else:
                return apology("Cannot retrieve quote")

Here is the html

{% extends "layout.html" %}

{% block title %}
    Quote
{% endblock %}

{% block main %}
    <form action="/quote" method="post">
        <div class="form-group">
            <input autocomplete="off" autofocus class="form-control" name="stock" placeholder="Stock Symbol" type="text">
        </div>
        <button class="btn btn-primary" type="submit">Quote</button>
    </form>
{% endblock %}

I have the latest (I think) distribution code and I have exported the API key. Here is my code and it keeps returning 'None'. I can't figure out why I can't look up a stock quote. Do I need to change the helper.py function for lookup? Because I assumed that was already written fully.

@app.route("/quote", methods=["GET", "POST"])
@login_required
def quote():
    """Get stock quote."""
    if request.method == "GET":
        return render_template("quote.html")
    else:
        # lookup symbol that was submitted
        if not request.form.get("stock"):
            return apology("must provide stock symbol")
        else:
            symbol = request.form.get("stock")
            quote = lookup(symbol)
            if quote != None:
                return render_template("quoted.html", quote=quote)
            else:
                return apology("Cannot retrieve quote")

I have the latest (I think) distribution code and I have exported the API key. Here is my code and it keeps returning 'None'. I can't figure out why I can't look up a stock quote. Do I need to change the helper.py function for lookup? Because I assumed that was already written fully.

@app.route("/quote", methods=["GET", "POST"])
@login_required
def quote():
    """Get stock quote."""
    if request.method == "GET":
        return render_template("quote.html")
    else:
        # lookup symbol that was submitted
        if not request.form.get("stock"):
            return apology("must provide stock symbol")
        else:
            symbol = request.form.get("stock")
            quote = lookup(symbol)
            if quote != None:
                return render_template("quoted.html", quote=quote)
            else:
                return apology("Cannot retrieve quote")

Here is the html

{% extends "layout.html" %}

{% block title %}
    Quote
{% endblock %}

{% block main %}
    <form action="/quote" method="post">
        <div class="form-group">
            <input autocomplete="off" autofocus class="form-control" name="stock" placeholder="Stock Symbol" type="text">
        </div>
        <button class="btn btn-primary" type="submit">Quote</button>
    </form>
{% endblock %}
Source Link

Why does my lookup function keep returning "None"?

I have the latest (I think) distribution code and I have exported the API key. Here is my code and it keeps returning 'None'. I can't figure out why I can't look up a stock quote. Do I need to change the helper.py function for lookup? Because I assumed that was already written fully.

@app.route("/quote", methods=["GET", "POST"])
@login_required
def quote():
    """Get stock quote."""
    if request.method == "GET":
        return render_template("quote.html")
    else:
        # lookup symbol that was submitted
        if not request.form.get("stock"):
            return apology("must provide stock symbol")
        else:
            symbol = request.form.get("stock")
            quote = lookup(symbol)
            if quote != None:
                return render_template("quoted.html", quote=quote)
            else:
                return apology("Cannot retrieve quote")