0

I am finally done with implementing my stock-trading website. Anyhow, I have some last questions before wrapping up and hope that someone can help me out to make sure I understand everything in this problem set.

  1. This question is in regard to those buttons in the HTML forms. How does, for instance, the "search" button in quote.html output a quoted.html? Even if I altered the "search" button from being of type "submit" to being of type "text," the button, when clicked, still knows how to bring a user from quote.html to quoted.html. Of course I know that transition is possible because that's how I wrote my code, but why is it that the "search" button triggers this transition? (I hope you understand what I am asking about...)

  2. I looked up the Internet and listened to all lecture materials. Just to be sure -- what are the differences between the method GET and the method POST? (Please reiterate the differences in plain, jargon-free English...)

  3. Nowhere in application.py was the table USERS created. How was 'USERS' created at the first place?

  4. Stupid question - what exactly is inside finance.db?

  5. Last but not least, how do we check our grades? I used to do it through the Gradebook here: http://apps.cs50.edx.org/cs50x/2016/@/portal, but ever since they revised the system or something, it seems like grades are not published the same way.

I can't thank enough for any kind of assistance. Gracias!

1
  1. The button does the action defined in the action attribute of the <form> tag. text is not a valid type for a button (see MDN doc on button and form) but it doesn't fail because, well, browsers have to be very (very) forgiving because there is a lot of bad code out there. If you validate your code (type="text") with a code validator (for example Nu Html Checker), it would report an error because text is not a valid button type.
  2. Again from MDN, "Requests using GET should only retrieve data." and a POST request "... results in a change on the server". Another (simple) difference: GET shows the query string (eg /search?q=02138) in the address bar, POST does not.
  3. The USERS table was not created in the software, it "came that way" in the downloaded finance.db.
  4. finance.db is "the main database file". Here is the technical discussion from sqlite.org. Besides all the header stuff, the data you put into the database ("INSERT") is "in there". Just like a .xlsx file has the rows and columns of a spreadsheet.
  5. Last but not least, sorry I don't know! Does this reddit post help?
1
  • Thanks again @DinoCoderSaurus !!!! – Alex Chan May 7 '17 at 20:57
1

I'm no expert, but I thought I'd give it a try since I just finished the problem set myself:

Your questions 1 and 2 are related. GET and POST are methods that determine how data is submitted to the server. With GET the data is appended to the URL (for example when you search 'cats' on Google, you can see 'cats' in the search results' URL). POST carries the submitted data in the message body which makes it more secure.

The quote function outputs quoted.html because your code determines that when the request method is POST (which is the case anytime you submit data), quoted.html will be rendered. On the other hand, quote.html appears when you have reached the quote route via GET (as by clicking the link or via redirect).

The tables 'users' and 'portfolio'/'transactions' (and possibly 'history') are not created in applications.py. You create the tables in the phpLiteAdmin. The 'users' table was already created for us by CS50 staff; the others we have to implement ourselves.

Finance.db is the database in phpLiteAdmin that contains all of your tables ('users', etc.).

You can check your grades on CS50.me. On the top right is a button called 'View Gradebook' that lists all your grades. You need a GitHub account in order to submit your problem sets.

1
  • Thank you @Bella !!!! – Alex Chan May 7 '17 at 20:56

You must log in to answer this question.

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