Skip to content

Individual Contribution Report 2 | Emre Türker

Emre edited this page May 12, 2023 · 3 revisions

Issues and tasks related to the Practice Application

Third-Party URLs

During this project, I have made use of the Bored API. The Bored API is a free public API that provides a way for developers to access a database of activity suggestions for people who are bored and looking for something to do. The suggestions range from "Learn Kotlin" to "Go to the gym".

I used this application to implement the GET functionality. The URL I have sent requests to is:

http://www.boredapi.com/api/activity/ This request takes no argument, and returns a response that includes the activity name.

API Handler Functions

I have implemented 4 endpoints.

  • **"bored()" -- "/bored"**: Whenever a GET request comes to this endpoint, the handler function sends a request to the Bored API and presents the response by rendering a HTML page to the client.
  • **"bored_save()" -- "/bored/save"**: Whenever a POST request comes to this endpoint, the handler functions takes the input activity and saves it to the database
  • **"get_bored_saved()" -- "/bored/getSaved"**: Whenever a GET request comes to this endpoint, the handler function runs a query and gets all the activities that are stored in the database and renders an HTML page to the client with the activities in it.
  • **"delete_bored_saved()" -- "/bored/delete"**: Whenever a POST request comes to this endpoint, the handler function runs a query and deletes all the activities that are present in the database.

Unit Test

There are 7 unit tests that I have included

  • test_signup() => Checks if the user was able to successfully sign up to the system
  • test_login() => Checks if the user was able to successfully log in to the system, and that the user is a member of the system.
  • test_invalied_login() => Checks if the system was able to detect that the user was not a member of the system.
  • test_save_bored() => Checks if a mockup activity was successfully saved to the database
  • test_show_saved_activities() => Checks if the system was able to show all the activities that are present in the database

Example API Calls

Since I am directly rendering HTML templates from the server, there is no actual JSON data that is going on between the frontend and backend. If we had an actual frontend that was sending real AJAX calls rather than using HTML templating I could easily detect the JSON information that was sent back and forth.

The Bored API Call

The request header that I send to the Bored API is as follows

image

The request body is empty.

The response is as follows

{ "activity": "Learn to write with your nondominant hand", "type": "recreational", "participants": 1, "price": 0, "link": "", "key": "1645485", "accessibility": 0.02 }

Challenges

The hardest challenge I have come across was how counter intuitive was the Flask framework. I am used to the mechanics Node.js and Go, and I believe that the rendering mechanism of Flask was a real pain.

Clone this wiki locally