Skip to content
Advertisement

CS50(2021) – Finance. :( registration rejects duplicate username – expected status code 200, but got 400

I´m new to programming, doing CS50 and currently struggling to complete the Pset9 – Finance, version from 2021. I´ve read as many threads I could find about the same issue, but none of the answers helped me to solve the problem yet.

Application.py is doing what the problem briefing required, and I passed all tests except for this one, check50 is expecting a status code 200 but I send a 400.

Check50 failed

Something to keep in mind:

  • Registration works as expected. I am able to register new users, and when the same username tries to register I show a 400 error.
  • Index function is completed, and fully functional showing all required data.
  • No script in Register.html to check username when pressing the submit button. I have been unable to write the right script. Not sure if this is something CS50 is expecting after all, but happy to hear anyone who has passed this test.

I would really appreciate it if someone can take a look at the code below, and let me know if I am doing something wrong or just point me in the right direction. Thanks in advance!

Here is my code for register in application.py :

JavaScript

Here is index in application.py :

JavaScript

Here is Register.html:

{% extends “layout.html” %}

JavaScript

And here is index.html:

JavaScript

Advertisement

Answer

The issue was finally fixed when I deleted all my data in users.db thencheck50 passed it correctly. It seems that data was causing the whole problem, and once deleted everything got fixed.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement