This project enables you to do the following:
- Add a question with specific category and difficulty
- Display all questions in the Home page or List page
- Get questions per category if you clicked on any category at Home page
- Search for specific word in any question, all matched questions shall be displayed in search result regardlress of their category
- Delete a question using the 'bin' button under each displayed question
- Show question answer by clicking on 'Show Answer'
- Play the trivia game which is:
- Choose one category to get questions from, or Choose 'All' to get questions from any category
- A question shall be displayed and you have to guess the answer
- Submit the answers
- The quiz composed of 5 questions and after you submitted all the answers, a final score appears for you
- After finishing the quiz 5 questions and got the score, you can play again!
- Python 3.7 should be installed at your machine
- Clone the project's repo
- Navigate to
'/backend'
and install all project's dependencies by running this command at your CMD:
pip install -r requirements.txt
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
SQLAlchemy is the Python SQL toolkit and ORM we'll use handle the lightweight postgres database.
-
Flask-CORS is the extension we'll use to handle cross origin requests from our frontend server.
- In order to run the application, type these commands at your CMD:
set FLASK_APP=flaskr
set FLASK_ENV=development
flask run
Where:
- Setting the
FLASK_ENV
variable todevelopment
will detect file changes and restart the server automatically. - Setting the
FLASK_APP
variable toflaskr
directs flask to use theflaskr
directory and the__init__.py
file to find the application. - Application runs on 'http://127.0.0.1:5000/' by default
- In order to run the website and visualize it, navigate to
'/frontend'
and type these commands at your CMD:
npm install
npm start
The website frontend runs on 'http://localhost:3000/' and it opens immediately as 'React App' at your browser
- Make sure to connect to the postgres database by configuring it in
'/backend/models.py'
In order to run tests, navigate to '/backend'
and run the following commands at the CMD:
dropdb trivia_test
createdb trivia_test
psql trivia_test < trivia.psql
python test_flaskr.py
Note: If this is your first time to run tests, you don't have to execute the 'dropdb' command
All tests are implemented in test_flask.py and should be maintained and updated if any changes occured in the backend endpoints handlers to make sure that the application is behaving correctly
Please check the 'README' file included in '/backend'
folder for reference
Software Engineer: Yousif Elhady
Thanks to all my mentors and colleagues at Udacity Web development nano-degree program