0

I'm trying to understand why my template, even though copied from a working "login" html and py file, doesn't render for "quote".

It just goes straight to return apology.. while the same code works in login, which allows me for an input before it executes apology.

python file:

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

    if request.method == "GET":
        if not request.form.get("symbol"):
            return apology("provide a symbol")

quote.hmtl:

{% extends "layout.html" %}

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

{% block main %}
    <form action="{{ url_for('quote') }}" method="get">
        <fieldset>
            <div class="form-group">
                <input autocomplete="off" autofocus class="form-control" name="symbol" placeholder="Symbol" type="text"/>
            </div>

            <div class="form-group">
                <button class="btn btn-default" type="submit">Quote</button>
            </div>
        </fieldset>
    </form>
{% endblock %}

1 Answer 1

0

In python file change if request.method == "GET" to if request.method == "POST" and also alter the method = "get" attribute in html form of quote.html to method = "post".

You must log in to answer this question.

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