A full-stack trivia web application built with Flask and React. Manage trivia questions by category and difficulty, search the question bank, and play a quiz game — all from a clean browser UI.
Features:
- Display questions (all or by category) with question, category, difficulty, and show/hide answer.
- Delete questions.
- Add questions with required question and answer text.
- Search for questions based on a text query string.
- Play the quiz game, randomizing either all questions or within a specific category.
- Python 3.7+
- Node.js & npm
- PostgreSQL
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtcd frontend
npm installWorking within a virtual environment is recommended.
With Postgres running, restore the database using the provided seed file:
createdb trivia
psql trivia < backend/trivia.psqlFrom the backend directory:
export FLASK_APP=flaskr
export FLASK_ENV=development
flask runcd frontend
npm startOpen http://localhost:3000 to view it in the browser.
dropdb trivia_test
createdb trivia_test
psql trivia_test < backend/trivia.psql
cd backend && python test_flaskr.py- Base URL:
http://127.0.0.1:5000/ - Authentication: None (not yet implemented)
Errors are returned as JSON:
{
"success": false,
"error": 422,
"message": "Unprocessable entity"
}Error codes: 400, 404, 422, 500
Returns all categories.
curl http://127.0.0.1:5000/categoriesReturns paginated questions. Use ?page= query parameter.
curl http://127.0.0.1:5000/questions?page=1Deletes a question by id.
curl http://127.0.0.1:5000/questions/6 -X DELETECreates a new question or searches (if body contains searchTerm).
curl http://127.0.0.1:5000/questions -X POST -H "Content-Type: application/json" \
-d '{"question": "...", "answer": "...", "difficulty": 3, "category": "6"}'Returns questions for a specific category.
curl http://127.0.0.1:5000/categories/1/questionsReturns a random question not in previous_questions for the given category.
curl http://127.0.0.1:5000/quizzes -X POST -H "Content-Type: application/json" \
-d '{"previous_questions": [5, 9], "quiz_category": {"type": "History", "id": "4"}}'- Sanjay Santhanam — API, test suite, and project maintenance
- Udacity — Starter files and frontend scaffold
This project is licensed under the MIT License — see the LICENSE file for details.