Quiz

  1. Request can only be used with existing APIs?

    the requests module allows you to write a front end. You'll need a back-end to talk to, either an existing one or one you create. You'll create one in the Ajax assignment. I'll provide the front end.

  2. I'm trying to put this topic together with what we have previously learned. Is the Python requests module something that allows for us to send data back and forth to the web page in an easier way? How does this combine with the Ajax reading?

    Yes. Well, maybe not easier. Just differently.

    The Ajax reading is about providing a different back-end, but still talking over HTTP.

  3. I think I'm still a little lost as to why we want to use get request and post request as opposed to just get and post. Also a little lost as to why we would want to do sessions with requests (I thought that sessions are about maintaining continuity, whereas requests seem mainly about getting data?). Can you give an example of when we would want to do this?

    I'm not sure I understand your question. There's no difference here: "get request and post request as opposed to just get and post"

    There's an example in the reading: where one request logs us in, and subsequent requests make use of that.

  4. Will the resp variable always have .status_code, .text, and .json, and nothing else?

    Well, it also has .cookies. There are other attributes; see the documentation.

  5. What is the difference between the answer choices for Question 3, specifically creating a session object vs setting the session variable? Also, are we saving the cookies that are sent back to us in a global session variable?

    The session object and session variable are things I invented as distractors (incorrect answers).

    In the example, the cookies are saved in a global variable. See sessions

  6. Would this not still work if we consistently called the 'sessions' variable 'pinkUnicorns' instead?

    Correct.

  7. Can we walk through this in class?

    Sure!