I cannot figure out why my quote form does not display. It jumps straight to the apology function and never prompts the user for a stock symbol.

HTML code from quote.html

{% extends "layout.html" %}

{% block title %}
    symbol search
{% endblock %}

{% block main %}
    <form action="{{ url_for('quote') }}">
            <div class="form-group">
                <input autofocus class="form-control" name="symbol" placeholder="Symbol" type="text"/>
            <div class="form-group">
                <button class="btn btn-default" type="submit">search</button>
{% endblock %}

Code from applications.py:

@app.route("/quote", methods=["GET", "POST"])
def quote():

    # ensure symbol was requested
    if not request.form.get("symbol"):
        return apology("please include a symbol") 

    # lookup symbol from provided by user
    quote = lookup(request.form.get("symbol"))

    # ensure symbol is correct
    if not quote:
        return apology("stock is not valid")

    # render next template
    return render_template("quoted.html") 

Thank you!

1 Answer 1


It's expecting a symbol to have been entered before you would ever have the chance to enter one. If you have a separate quote and quoted page, you need to create a new route in your application. Then, when you open the quote page, it simply renders the template, but when you open the quoted page, it does a bit more work!

You must log in to answer this question.

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