This is a RESTful API built with FastAPI that allows users to create questions with multiple choices, retrieve questions, and their corresponding choices from the database.
- Create questions with multiple choices.
- Retrieve a specific question and its details.
- List all choices for a specific question.
- FastAPI
- SQLAlchemy
- Pydantic
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before you begin, ensure you have met the following requirements:
- Python 3.8+
- pip
- Clone the repository:
git clone https://github.com/am-niz/question_choices_app_api.git
cd question_choices_app_api
- Install the required packages:
pip install -r requirements.txt
- Create a
.env
file in the root directory of the project and add your database URL:
DATABASE_URL="sqlite:///./test.db"
(Replace the value with the connection string appropriate for your database.)
- Run the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
POST /questions/
Request body:
{
"question_text": "What is the capital of France?",
"choices": [
{"choice_text": "Paris", "is_correct": true},
{"choice_text": "Berlin", "is_correct": false},
{"choice_text": "Madrid", "is_correct": false}
]
}
GET /questions/{question_id}
Replace {question_id}
with the id of the question you want to retrieve.
GET /choices/{question_id}
Replace {question_id}
with the id of the question for which you want to list all choices.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Distributed under the MIT License. See LICENSE
for more information.
Gamil: - [email protected]
Project Link: https://github.com/am-niz/question_choices_app_api