Compare commits

...

4 Commits

Author SHA1 Message Date
Chris Proctor
6946f63d19 Add assessment 2024-05-20 23:48:32 -04:00
Danielle Tear
c33b40af81 Forgot to add Checkpoint 2 requests to the notes.
They are there now :)
2024-03-11 18:12:01 -04:00
Danielle Tear
6de3b3ab61 Completed Checkpoints 2 and 3.
One Internet-enabled service that I use regularly
is Life360. You can get a record of a family
member's location history which seems like an HTTP
get request. Creating a family group seems like an
HTTP post.

Yes, this lab has caused me to think differently
about the tech interactions in my daily life. I
never really considered before how different
applications and devices communicate with info
that is stored on a server. Of course I understood
that all the information could not possibly be
stored on a phone or laptop, but I was not
completely aware of what was actually going on
behind the scenes. I think I will be a lot more
concious of the presence of HTTP requests now in
my daily life.
2024-03-11 15:55:16 -04:00
Danielle Tear
404a674898 Completed Checkpoint 1 2024-03-08 22:41:27 -05:00
4 changed files with 59 additions and 3 deletions

Binary file not shown.

18
api.py
View File

@@ -36,16 +36,28 @@ class RiddleAPI:
def get_riddle(self, riddle_id):
"Fetches a single riddle from the server"
route = "/show"
raise NotImplementedError("The API doesn't support `get_riddle` yet. Can you add it?")
params = {'id' : riddle_id}
response = requests.get(self.server_url + route, json=params)
if response.ok:
return response.json()
else:
raise APIError(response.json()['errors'])
def get_random_riddle(self):
"Fetches all riddles from the server and then randomly returns one"
raise NotImplementedError("The API doesn't support `get_random_riddle` yet. Can you add it?")
riddles = self.get_all_riddles()
riddle = choice(riddles)
return riddle
def add_riddle(self, question, answer):
"Adds a new riddle to the server"
route = "/new"
raise NotImplementedError("The API doesn't support `add_riddle` yet. Can you add it?")
params = {'question': question, 'answer': answer}
response = requests.post(self.server_url + route, json=params)
if response.ok:
return response.json()
else:
raise APIError(response.json()['errors'])

19
assessment.md Normal file
View File

@@ -0,0 +1,19 @@
# Riddles Lab Assessment
Everything looks good! I found your reflection in your commit message really interesting:
> Yes, this lab has caused me to think differently
> about the tech interactions in my daily life. I
> never really considered before how different
> applications and devices communicate with info
> that is stored on a server. Of course I understood
> that all the information could not possibly be
> stored on a phone or laptop, but I was not
> completely aware of what was actually going on
> behind the scenes. I think I will be a lot more
> concious of the presence of HTTP requests now in
> my daily life.
I think this kind of connection between formal CS learning in the classroom and
everyday tech-mediated experiences is incredibly important!

View File

@@ -7,7 +7,32 @@ about the meaning of the line, and some situation in which it might be useful.
You are welcome to research the meanings of these headers, but it's also
fine to speculate for now.
Line 5: Keeps the connection open for multiple requests/responses.
Line 6: Shows where the request is being sent
Line 7: This shows who is making the HTTP request.
Line 13: This shows the length of the requested information.
Line 14: This shows the filetype of what was requested.
## Checkpoint 2
The goal of this checkpoint is to see what status codes you can get back from
the riddle server. Paste below several `http` requests and the status codes
they return.
400 Bad Request:
http -v post https://riddles.makingwithcode.org/guess id=1000 answer="a short-legged cow"
http -v post https://riddles.makingwithcode.org/guess id=invalid_id answer="a short-legged cow"
404 Not Found:
http -v post https://riddles.makingwithcode.org/guess/this_is_wrong id=1 answer="a short-legged cow"
http -v post https://riddles.makingwithcode.org/guessssssssssssssss id=1 answer="a short-legged cow"
405 Method Not Found:
http -v posts https://riddles.makingwithcode.org/guess id=1 answer="a short-legged cow"
http -v invalidmethod https://riddles.makingwithcode.org/guess id=1 answer="a short-legged cow"