Skip to content

amin7mazaheri/haselmeier_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

follow the below steps:

virtualenv -p python3 env
source env/bin/activae 
python manage.py migrate 
python manage.py createsuperuser
username:admin
password:admin
python manage.py runserver 127.0.0.1:8000

Test

run tests(test_views , test_models)

python manage.py test

Go to the admin panel and add some data for testing

''' 127.0.0.1:8000/admin/ '''

I used sqlite3(default of django as relational database )

Usage

for using APIs login and receive an access token

Geting access token:

curl  -X post http://127.0.0.1:8000/api/token/ -d username=admin -d password=admin

Answer is Json with two values refresh and access select access.(this token will expire after 5 mins) refresh is used for getting new access token(refresh will expire after 24 hours)

Using API's

Adding new book

 curl  -X post http://127.0.0.1:8000/api/book/  -H "Content-Type: application/json ,Authorization: Bearer MYTOKEN"  -d '{"name":"xyz","price":"xyz", "author":"xyz", "publisher":"xyz"}'

Getting list of book

 curl  -X get http://127.0.0.1:8000/api/book/  -H "Authorization: Bearer MYTOKEN"

Get detail of book

 curl  -X get http://127.0.0.1:8000/api/book/id/  -H "Authorization: Bearer MYTOKEN"

Delete rating

 curl  -X delete http://127.0.0.1:8000/api/rating/id/  -H "Content-Type: application/json ,Authorization: Bearer MYTOKEN" 

Adding new rating

 curl  -X post http://127.0.0.1:8000/api/rating/  -H "Content-Type: application/json ,Authorization: Bearer MYTOKEN"  -d '{"user"="xyz", "book"="xyz", "rating":"yxz"}'

Get list of rating

 curl  -X get http://127.0.0.1:8000/api/rating/  -H "Authorization: Bearer MYTOKEN"

Get detail of rating

 curl  -X get http://127.0.0.1:8000/api/rating/id/  -H "Authorization: Bearer MYTOKEN"

Delete book of stock

 curl  -X delete http://127.0.0.1:8000/api/stock/id/  -H "Content-Type: application/json ,Authorization: Bearer MYTOKEN" 

Adding new book to stock

 curl  -X post http://127.0.0.1:8000/api/stock/  -H "Content-Type: application/json ,Authorization: Bearer MYTOKEN"  -d '{"book":"xyz","in_stock":"xyz","quantity":"xyz"}'

Get detail of stock

 curl  -X get http://127.0.0.1:8000/api/stock/id/  -H "Authorization: Bearer MYTOKEN"

Get list of stock

 curl  -X get http://127.0.0.1:8000/api/stock/  -H "Authorization: Bearer MYTOKEN"

Using of Postam is another option

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages