0

I can't seem to get the lookup to work right. I just keep getting an error of "404 Not Found". Here is the URL and it does load but doesn't load when I post to it for some reason http://ide50-ndjustin20.cs50.io:8080/quote.html

Here is my python code:

@app.route("/quote", methods=["GET", "POST"])
@login_required
@nocache
def quote():
# User reached route via POST (as by submitting a form via POST)
    if request.method == "POST":

        symbolList = []
        symbol = request.form.get("symbol")
        symbolList = lookup(symbol)
        return render_template("quote.html", Name=symbolList[0], Price=symbolList[1], Symbol=symbolList[2])


    else:

         return render_template("quote.html")

Here is the template:

{% extends "layout.html" %}

{% block title %}
Search for a stock
{% endblock %}
    <main class="container p-5">
        {% block main %}


        <h1>Please Search Below</h1>
        <pre>
        <form action="/quote.html" method="post">

            <input name="symbol" type="text">

            <input type="submit">

        </form>

        </pre>

        {% if name %}
        <table>
            <thead name="thead">
               <tr>
                    <th>Name</th>
                    <th>Price</th>
                    <th>Symbol</th>
                </tr>
             </thead>


            <tbody>
                <tr>
                    <td>{{ Name }}</td>
                    <td>{{ Price }}</td>
                    <td>{{ Symbol }}</td>
                </tr>
            </tbody>



         </table>
        {% endif %}

        {% endblock %}
    </main>
1

One problem is here <form action="/quote.html" method="post">. There is not a quote.html in document root (it is in subdir templates), thus the 404. But do you really want the form action to be the html? Shouldn't it be the app route?

| improve this answer | |
  • Thank you for the feedback!! I can't believe I stared at that problem for that long and that's what it was. I wasn't trying to use the quote.html I just accidentally put in the .html as I was creating the template. Thanks again!! – ndjustin20 Apr 13 '18 at 13:58

You must log in to answer this question.

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