Within this short documentation, we want to show how to use the workflow api. This readme describes every step required to get going with your own object detection classifier:
- Requirements
- Build the API
- Unit tests
- Update databases
- API Endpoints
- Testing the API (Integration tests)
- Known problems with solutions
- Django==2.2.3
- Python==3.7.7
- djangorestframework==3.10.2
- drf-nested-routers
pip install -r requirements.txt
It uses django rest framework to build API. Here lets Build, run and test the app. It creats a nested serializer and uses HTTP REST methods to do all CRUD functions.
The figure shows the Overview of the project. This has app folder called workflowapp and project folder workflowapi.
This will built the django API with sqlite3 databases.
python manage.py migrate
python manage.py makemigrations workflowapp
This unit test test_comment.py
and test_workflow.py
checks:
- Create a workflow with API.
- GET a workflow with API.
- Update a workflow with API.
- Delete a workflow with API.
- Get workflow list.
- Create a comment with API.
- GET a comment with API.
- Update a comment with API.
- Delete a comment with API.
- Get comment list.
python manage.py test
This Update update_db.py
checks the model and serializers. This populates the databases with initial data. Here JSON data are provided for workflow and comment.
python update.py
Note: If error comes refer Known problems with solutions Known problems with solutions
This will start the localserver at : http://localhost:8000/
python manage.py runserver
- Access the admin: http://localhost:8000/admin/
- user: admin
- password: admin
or
Create a new superuser
python manage.py createsuperuser
- /workflow/: workflow-list(Todo create and list endpoint)
- /workflow/{pk}/: workflow-detail(Todo retrieve, update and destroy endpoint)
- /comment/: comment-list(Todo create and list endpoint)
- /comment/{pk}/: comment-detail(Todo retrieve, update and destroy endpoint)
API is tested using Insomnia for CRUD function. It is tested on workflow and comment api end points.
Let's make another post request, to create some data. Make a New Request and select the proper type & format. Then, complete the request URL/endpoint and body (make sure all required fields are included). Once you've done that, click on the HEADER tab. I want to make a header called basic Authorization e.g. (user: admin password: admin) .
The figure below shows the GET Request at API endpoint GET request for List of workflow at API endpoint
The figure below shows the GET Request at API endpoint GET request for List of workflow at API endpoint
Here we focus on discussions related to the user story.
sqlite3.OperationalError: no such table: workflowapp_workflow
python manage.py migrate --run-syncdb