Welcome to Quiz Game! This is a simple Flask web application where users can play a quiz game by answering multiple-choice questions.
- Clone the repository:
git clone https://github.com/1970Mr/quiz-game.git
cd quiz-game
- Set up a virtual environment (optional but recommended):
python -m venv venv
- Activate the virtual environment:
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
- Install the dependencies:
pip install -r requirements.txt
Create a .env file in the root directory of the project and set the following environment variables. You can use the provided .env.example file as a template:
ADMIN_USERNAME=your_admin_username
ADMIN_EMAIL=your_admin_email
ADMIN_PASSWORD=your_admin_password
NUM_QUESTIONS_PER_STAGE=your_number_questions_per_stage
You can seed initial data into the database, which includes creating the necessary tables and importing questions from a JSON file:
python initial_data.py path_to_json_file [--add-only]
path_to_json_file
: The path to the JSON file containing the questions.--add-only
: Optional flag to add new questions without resetting the existing ones.
For example:
python initial_data.py data/questions.json
If you want to add questions to the existing ones without resetting:
python initial_data.py data/questions.json --add-only
After seeding the initial data or importing questions, you can run the Flask application:
flask run
Then, open your web browser and go to http://localhost:5000/ to access the Quiz Game.
You can also run the application using Docker and Docker Compose. This approach ensures that you don't need to manually set up a virtual environment or install dependencies locally.
-
Build and run the Docker container:
docker-compose up --build
-
After the container is up and running, open your web browser and go to http://localhost:5000/ to access the Quiz Game.
This project was created as a learning exercise by MR.1970. Feel free to contribute or use it as a basis for your own projects.