0

I´ve been struggling to complete the Pset9 - Finance, version from 2021. After reading multiple threads I decided to post here the issue, looking for some guidance so I can move forward in the course.

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

[![All tests were passed except this one][1]][1]

Some areas of thought and considerations:

  • 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!

6
  • I ran check50 with this register and index functions; all passed. (The htmls should not affect this particular result). Try again? Sorry this isn't particularly helpful. Commented Feb 2, 2021 at 1:50
  • Thanks for checking my code @DinoCoderSaurus and running those tests again. Glad to hear they passed! Would this mean any other logic within application.py is affecting check50 when performing the registration duplicate test? Here is my full code just in case you can see this easily paste.ofcode.org/FFdACSDH9KLKbpat9AXAnU After reading your comment I tried again, but I always get the same error. How can I pass this one from my end? Ans if not possible, shall I submit as it is?
    – MrTxo
    Commented Feb 2, 2021 at 13:58
  • Can you please edit the schema definitions of users and stocks tables into the question? I ran check50 on this application.py plus register.html. It failed "register user " and the duplicate test because of a missing stocks table. I added a stocks table based on the code. Both tests passed check50. That leads me to the conclusion that the db schema (or perhaps data) is significant to the problem. Commented Feb 2, 2021 at 19:56
  • @DinoCoderSaurus just added a schema definition of both tables and a screenshot from each structure on phplite. Let me know if this is sufficient, or if you need me to add anything else. Thanks again for your help on this one!
    – MrTxo
    Commented Feb 2, 2021 at 20:20
  • Running check50 (version 3.2.0) on the IDE with this application.py, register.html and index.html and the two tables (empty) in finance.db passes all of the "register" tests. (and works as expected in the browser). You can find the check50 version with check50 -V. I won't stop thinking about it, which I know is no help at all. It may be time to contact [email protected] Commented Feb 3, 2021 at 0:08

1 Answer 1

1

The 'duplicate' check first registers a new user (which would return a 200) and then tries to register that same user (which would return a 400).

The error you are seeing saying it was expecting a 200 and didn't get it. That tells me that it is the initial registration that is failing.

If you delete all the rows from your user table and run check50 again, does it still fail?

3
  • 1
    Wow, that was it! I´ve been literally almost 3 weeks doing 100 different things on my code and at some point, it really looked impossible to solve but it was solved by pressing a button to empty the table. Lol. So for the record, I assume this has been caused as I already registered the very same name in the database, and once check50 tried got 400 instead of 200. I cannot thank you enough for helping me out here! THANK YOU! :)
    – MrTxo
    Commented Feb 5, 2021 at 18:01
  • I have same error message and followed the suggestion here. My table is empty but the error message is still there. Any advice please.
    – Idongesit
    Commented Mar 6, 2021 at 22:23
  • Hello. I am facing the same issue and I don't know how to delete users table to fix it. can you tell me how to do that? thanks Commented Dec 15, 2023 at 19:46

You must log in to answer this question.

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