This repository contains the backend (BE) part of a simple calculator application. The backend is responsible for processing calculation requests sent from the frontend, evaluating mathematical expressions, and returning the results. It's built with Django and Django REST Framework (DRF) for a RESTful API and uses Celery for asynchronous task processing.
- RESTful API: Exposes endpoints for creating and fetching calculations.
- Asynchronous Processing: Utilizes Celery for handling calculation tasks asynchronously.
- Security: Implements basic checks to ensure only safe mathematical expressions are evaluated.
Before starting, ensure you have Python and pip installed on your system. Then, follow these steps:
- Clone the Repository
git clone https://github.com/zdwarren/calc-be.git
cd calc-be
- Create and Activate a Virtual Environment
For Unix/macOS:
python3 -m venv env
source env/bin/activate
For Windows:
python -m venv env
.\env\Scripts\activate
- Install Requirements
pip install -r requirements.txt
- Apply Migrations
python manage.py migrate
- Run the Development Server
python manage.py runserver
To process calculations asynchronously, you need to run a Celery worker alongside the development server. Open a new terminal, activate the virtual environment as shown above, and run:
celery -A calc_be worker --loglevel=info --pool=solo