Trivo is a trivia game API that I built to practice full stack programming as part of my Full Stack Nanodegree from Udacity.
It uses flask as a web framework, PostgreSQL as the database of choice and SqlAlchemy as the ORM
It demonstrates my understanding of API creation, error handling,full documentation and unit testing.
Flask was used as a backend using python. PostgreSql as the database I used. SQLAlchemy as the ORM of choice.
-
Get a list of categories.
-
Get a list of questions in a given category.
-
Search questions.
-
Post question.
-
Delete question.
-
Start playing the game.
{
"briefing": "Welcome to the trivia API, below is the list of the available endpoints, for more information check our documentation file",
"endPoints": {
"/api/categories": {
"function": "get_categories",
"methods": [
"GET"
]
},
"/api/categories/<int:category_id>/questions": {
"function": "get_question",
"methods": [
"GET"
]
},
"/api/questions": {
"function": "post_question",
"methods": [
"POST"
]
},
"/api/questions/<int:question_id>": {
"function": "delete_question",
"methods": [
"DELETE"
]
},
"/api/questions/search": {
"function": "search_questions",
"methods": [
"POST"
]
},
"/api/quizzes": {
"function": "start_quizz",
"methods": [
"POST"
]
}
},
"success": true
}
For a detailed documentation Full documentation.
A test_flask.py file is included that includes a comprehensive list of unit tests. The PostgreSQL connection string needs to be supplied below
self.database_path = "postgres://{}/{}".format('postgres:root@localhost:5432', self.database_name)
a psql file is provided trivia.psql we a list of initial questions which can be imported to your PostgreSQL instance
You can get the project up and running in 3 simple steps.
- Use the following command to install the required packages
pip install -r requirements.txt
- Edit the models.py file and add your PostgreSQL connection string
database_path = "postgres://{}/{}".format('CONNECTION_STRING', database_name)
- Use The following command to start the server and voila!
set FLASK_APP=flaskr
set FLASK_ENV=development
flask run