Tech Stack
- Python
- Flask
- PostgreSQL
- React
- CSS
This full-stack responsive web app allows users to add and delete questions and play a mini quiz. I built it to review my understanding of RESTful API service. This is also the second project I completed as part of my Udacity Full Stack Web Developer Nanodegree. As a full-stack application, it consists of both the frontend and backend.
The technologies used for the frontend were React, jQuery and CSS. As most of the logic for rendering the pages had been implemented, I decided to improve upon it by:
button
tags, the list elements, and its items respectively with ul
and li
tags, and using section
, article
and details
tags where appropriateThe technologies used for the backend were Python, Flask, and PostgreSQL. The primary features of the application are listed below:
For each page to work as expected, I created 7 endpoints:
To play the quiz, a user must navigate to the quiz page and select a category; afterwards, a max of 5 questions is displayed in turns, and the user’s final score will be displayed on the screen. When a user selects a category, the quiz page makes an API request to the server with a request body that includes an array of the previously asked questions’ ids and the category the user selected. The request would look like this:
{
"previous_questions": [18, 19],
"quiz_category": { "type": "Art", "id": "2"}
}
Whenever this request is sent, the function that is executed does the following:
The response to that request is a JSON object that includes the following question to be displayed. The response would look like this:
{
"success": True,
"question": {
"answer": "Escher",
"category": 2,
"difficulty": 1,
"id": 16,
"question": "Which Dutch graphic artist–initials M C was a creator of optical illusions?"
}
}
For the frontend aspect of this project, I got to use the HTML tags details and summary for the first time in a project. I used it to reveal and hide the answers to questions on the home page. It was more efficient than writing a function that controls when to show or hide the answer depending on if a button is clicked.
When the answer details is clickedThe most exciting part of the backend aspect was the quiz page. I translated the requirements into code, and the code worked as expected.