HydroAPI is a simple Django-based API for managing hydroponic systems and their measurements.
Ensure you have the following installed on your machine:
Run the following Python code to generate a new secret key:
import secrets
print(secrets.token_urlsafe(50))Copy the generated secret key for later use.
Create a file named .env in the root directory of your project and add the following contents:
SECRET=
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=Replace fields with your credentials.
-
Build the Docker image:
docker-compose build
-
Start the Docker containers:
docker-compose up
-
Create superuser to access /admin panel: Access the backend container console and run
python manage.py createsuperuser
Your Django project should now be running on http://localhost:8000.
To interact with the API, you can use tools like Postman, curl or some designed frontend.
- Register:
POST /api/auth/register/ - Login:
POST /api/auth/login/ - Create Hydroponic System:
POST /api/hydro/ - Get Hydroponic Systems:
GET /api/hydro/ - Update Hydroponic System:
PUT /api/hydro/{id}/ - Delete Hydroponic System:
DELETE /api/hydro/{id}/ - Create Measurement:
POST /api/hydro/{id}/measurements/ - Get Measurements:
GET /api/hydro/{id}/measurements/
Refer to the API Documentation for detailed information on request and response formats.
- Ensure that your
Dockerfileanddocker-compose.ymlare correctly configured to use the.envvariables. - You might want to add more environment variables depending on your project's requirements (e.g., database settings).
- Make sure the
.envfile is listed in your.gitignoreto avoid exposing sensitive information.