0

My code passes check50 fine. But when I attempt to run my webserver, I keep getting a 400 error whenever I try to "submit"

Webserver

Error on submit

Error Message

Here's my .html file. I can't imagine that this is the problem as I tried using the staff solution but that also didn't work.

{% extends "layout.html" %}

{% block body %}

<div class="col">
    <form action="/compare" enctype="multipart/form-data" method="post">

        <!-- TODO -->
        File 1:<br>
        <input type="file" name="File 1">
        <br>
        File 2:<br>
        <input type="file" name="File 2">
        <br>
        Algorithm: <br>
        <input type="radio" name="Algorithm" value="Lines" checked> Lines<br>
        <input type="radio" name="Algorithm" value="Sentences"> Sentences<br>
        <input type="radio" name="Algorithm" value="Substrings"> Substrings<br><br>
        Length: <br>
        <input type="number" name="Length">
        <br>
        <button type="submit">Compare</button>
        <br>

    </form>
</div>

{% endblock %}
1

check50 doesn't check the form. Same for the similarities/more version.

There should have been an error message, and I have no idea why there wasn't (other than a generic "you're sending garbage I don't understand"). So I can tell you what you obviously did wrong and hope it fixes the issue.

If you open application.py and read function compare, there are several places where a 400 can be triggered. And you would hit all of them. Maybe re-read https://docs.cs50.net/2018/x/psets/6/similarities/less/similarities.html#code-templates-index-html-code-2 (in similar cases, it can often help to copy&paste variable names or strings you may not change)

 required     | you have
--------------+--------------
 "file1"      | "File 1"
 "file2"      | "File 2"
 "algorithm"  | "Algorithm"
 "lines"      | "Lines"
 "sentences"  | "Sentences"
 "substrings" | "Substrings"
 "length"     | "Length"
  • That did it. I didn't realize things have to be case sensitive. Thanks. – Coal143 May 4 '18 at 15:43
  • Not only case sensitive, also spaces in between (would you expect "file1"=="File 1"?) – Blauelf May 4 '18 at 16:06

You must log in to answer this question.

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