- Download the Repository to your local machine
- Create a Virtual Environment in the crop-disease-detection-app-backend folder with this command below
python -m venv venv
- Activate the environment with this command
.\venv\Scripts\activate
- Install the dependencies (like Django, Django-Rest-FrameWork)
pip install -r requirements.txt
- Activate the environment with this command.
.\venv\Scripts\activate
- Start the application by running this command (Run the command where manage.py is located) or
cd crop_disease_detection_app
python manage.py runserver
- You can access the admin panel by running the server and opening http://localhost:8000/admin
- Run
python manage.py createsuperuser
to create a user to access the admin panel. - Set up the Username and Password
- You can log in and change the database values anytime.
AN instance of this server is running on a machin at IIT Dharwad, and it can be accessed by using the URl: http://farmbook.iitdh.ac.in
- apis/Login/
- apis/SignUp/
- apis/SetData/
- apis/GetPastData/
- apis/GetSensorValueData/
- apis/SetVideoFrame/
- apis/SetSensorData/
- apis/GetCropRecommendation/
- apis/GetCropRecommendationWithGivenData/
This Api is used to validate the credentials entered by a user.
Send a POST
request to apis/login/
checkLogin
{
"user_name":"user1"
"password":"123"
}
{
"message":"User Verified"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | User Verified |
401 UNAUTHORIZED | Wrong Password |
401 UNAUTHORIZED | Enter Password |
404 NOT FOUND | User not found |
400 NOT FOUND | Bad Request |
This Api is used to create a new user with the given details.
Send a POST
request to apis/SignUp/
newSignup
{
"user_name":"user1",
"email":"[email protected]",
"password":"123"
}
{
"message":"User Created"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | User Created |
400 NOT FOUND | Bad Request |
This Api is used to create a new data object corresponding to the location data and the image.
Send a POST
request to apis/SetData/
setData
{
"time_stamp":"08/04/2022 16:28:24",
"latitude":"0.0",
"longitude":"0.0",
"probability":"0.95",
"predicted_class":"healthy",
"crop_name":"maize",
"user_name":"user1",
"image":"image file"
}
{
"message":"Data Object Created"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Data Object Created |
404 NOT FOUND | Predicted class not foundd |
404 NOT FOUND | Crop not found |
404 NOT FOUND | User not found |
400 NOT FOUND | Bad Request - python Exception |
This Api is used to get the data and the images associated with a user.
Send a POST
request to apis/GetPastData/
getPastData
{
"user_name":"user1",
"starting_index":"0"
}
{
"message":"Data Fetch Successful",
"data0":{
"time_stamp":"08/04/2022 16:19:27",
"latitude":"0.0" ,
"longitude":"0.0" ,
"predicted_class":"healthy" ,
"probability":"0.95",
"user":"user1",
"crop_type":"maize",
"file_name":"user1_maize_08-04-2022_16-19-27.png",
}
"max_index":0
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Data Fetch Successful |
400 NOT FOUND | Bad Request - python Exception |
This Api is used to get the sensor values associated to a user.
Send a POST
request to apis/GetSensorValueData/
getSensorValuesData
{
"user_name":"user1"
}
{
"message":"Sensors Data Fetch Successful",
"total_count":1,
"sensor_type":"humidity",
"latitude":"0.0",
"longitude":"0.0",
"user":"user1",
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Sensors Data Fetch Successful |
400 NOT FOUND | Bad Request - python Exception |
This Api is used to create a video frame object to store in the database.
Send a POST
request to apis/SetVideoFrame/
setVideoFrame
{
"time_stamp":"08/04/2022 16:28:24",
"start_latitude":"0.0",
"end_latitude":"0.0",
"start_latitude":"0.0",
"end_longitude":"0.0",
"probability":"0.95",
"predicted_class":"healthy",
"crop_name":"maize",
"user_name":"user1",
"image":"image file",
}
{
"message":"Data Object Created"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Data Object Created |
404 NOT FOUND | Predicted class not foundd |
404 NOT FOUND | Crop not found |
404 NOT FOUND | User not found |
400 NOT FOUND | Bad Request - python Exception |
This Api is used to create a sensor value object to store in the database.
Send a POST
request to apis/setSensorData/
setSensorData
{
"time_stamp":"08/04/2022 16:28:24",
"latitude":"0.0",
"longitude":"0.0",
"sensor_type":"humidity",
"value":"100.00"
}
{
"message":"Value Added to the sensor"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Value Added to the sensor |
200 OK | New sensor added and appended value |
404 NOT FOUND | Predicted class not foundd |
404 NOT FOUND | sensor type not found |
404 NOT FOUND | user not found |
400 NOT FOUND | Bad Request |
This Api is used to give a recommendation based on the existing data in the database.
Send a POST
request to apis/GetCropRecommendation/
getCropRecommendation
{
"latitude":"0.0",
"longitude":"0.0",
"user_name":"user1",
}
{
"message":"Data present",
"full_data":1,
"predicted_crop":"maize"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Data present |
200 OK | Data not present |
400 NOT FOUND | Bad Request - python Exception |
This Api is used to give a recommendation based on the given data in the request.
Send a POST
request to apis/GetCropRecommendationWithGivenData/
GetCropRecommendationWithGivenData
{
"latitude":"0.0",
"longitude":"0.0",
"user_name":"user1",
"nitrogen":"0.5",
"phosphorus":"0.5",
"potassium":"0.5",
"pH":"7",
"temperature":"40",
"humidity":"40"
}
{
"message":"Crop recommended successfully",
"full_data":1,
"predicted_crop":"maize"
}
The possible responses for this api request are as follows
Status Codes | Possible Messages |
---|---|
200 OK | Crop recommended successfully |
400 NOT FOUND | Bad Request - python Exception |