The Fizzbuzz API is a Django REST framework-based backend service that provides an API for managing Fizzbuzz items. This service allows clients to retrieve a list of Fizzbuzz items and create new ones.
- Retrieve a list of all Fizzbuzz items
- Retrieve detailed view of a Fizzbuzz item
- Create new Fizzbuzz items
- Python 3.8
- Django 3.2
- Django REST Framework
Clone the repository and set up a local development environment:
git clone https://github.com/ahmadrezatabibi/fizzbuzz.git
cd fizzbuzz
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
python manage.py makemigrations fizzbuzz
python manage.py migrate
python manage.py runserver
Visit http://127.0.0.1:8000/fizzbuzz
in your browser to view the browsable API.
For local development, set the following environment variables:
export DJANGO_SECRET_KEY='your_secret_key'
export DJANGO_DEBUG='True'
export DJANGO_ALLOWED_HOSTS='localhost,127.0.0.1'
For production environments, ensure DJANGO_DEBUG
is set to False
and configure DJANGO_ALLOWED_HOSTS
with your actual domain names or IP addresses.
- Endpoint:
GET /fizzbuzz
- Response Body:
[ { "fizzbuzz_id": 1, "creation_date": "2024-02-11T01:09:41.679514Z", "message": "Example Fizzbuzz message", "user_agent": "Mozilla/5.0" } ]
- Endpoint:
GET /fizzbuzz/{id}
- Response Body:
{ "fizzbuzz_id": 1, "creation_date": "2024-02-11T01:09:41.679514Z", "message": "Example Fizzbuzz message", "user_agent": "Mozilla/5.0" }
- Endpoint:
POST /fizzbuzz
- Request Body:
{ "message": "New Fizzbuzz message", "user_agent": "Mozilla/5.0" }
- Response Body:
{ "fizzbuzz_id": 2, "creation_date": "2024-02-11T01:09:41.679514Z", "message": "New Fizzbuzz message", "user_agent": "Mozilla/5.0" }
Run tests using the Django test framework:
python manage.py test