This application is a simple Employee Management System built with Django and MySQL. It allows you to create, retrieve, update, and delete employee records via RESTful API endpoints. The application is containerized using Docker, making it easy to deploy and run in different environments. The backend is powered by Django, and the MySQL database is used to store employee information.
- Docker
Run the db:
docker run --name mySQL --network keploy-network -e MYSQL_ROOT_PASSWORD=keploy -e MYSQL_DATABASE=keploy_db -e MYSQL_USER=admin -e MYSQL_PASSWORD=keploy -p 3306:3306 -d mysql
In the project root directory, run:
docker build --build-arg HOST_PWD="$(pwd)" -t py-app .
docker run --name django-app --net keploy-network -p 8000:8000 -v "$(pwd):$(pwd)" --rm py-app
• Create Employee (POST): http://localhost:8000/api/employee/create/
• Get Employee by ID (GET): http://localhost:8000/api/employee/{id}/
• Get All Employees (GET): http://localhost:8000/api/employee/
• Update Employee (PUT): http://localhost:8000/api/employee/update/{id}/
• Delete Employee (DELETE): http://localhost:8000/api/employee/delete/{id}/
Now, you can send the following request payload to create a new employee with an additional field
:
{
"name": "John Doe",
"years_of_experience": 5,
"field": "Computer Science",
"company": "TechCorp"
}
Example CURL for creating an employee:
curl -X POST http://localhost:8000/api/employee/create/ -H "Content-Type: application/json" -d '{"name": "John Doe", "years_of_experience": 5, "field": "Computer Science", "company": "TechCorp"}'
Django application runs on port 8000.
Use the following curl commands to test the APIs after running the application:
curl -X POST http://localhost:8000/api/employee/create/ -H "Content-Type: application/json" -d '{"name": "John Doe", "years_of_experience": 5, "field": "Computer Science", "company": "TechCorp"}'
curl -X GET http://localhost:8000/api/employee/
curl -X GET http://localhost:8000/api/employee/1/
curl -X PUT http://localhost:8000/api/employee/update/1/ -H "Content-Type: application/json" -d '{"name": "Jane Doe", "years_of_experience": 6, "field": "Data Science", "company": "TechCorp"}'
curl -X DELETE http://localhost:8000/api/employee/delete/1/