Giter Site home page Giter Site logo

groovytunes's Introduction

Example request

For route /api/users/auth/register/ PUSH

{
    "email": "[email protected]",
    "password1": "Testownik112",
    "password2": "Testownik112"
}
reply:
{
    "key": "69bd0b781517098c3a782737f64554381dd9411b"
}

For route /api/users/auth/api-token-auth/ PUSH

body:
KEY		VALUE
username:	johannes
password	password321
reply:
{
   "token": "6474f20911b0342eb2e5a6afb65f756cf43c9f37"
}

For route /api/users/auth/user/ GET

header:
KEY		VALUE
Authorization	Token 6474f20911b0342eb2e5a6afb65f756cf43c9f37
reply:
{
    "pk": 6,
    "username": "johannes",
    "email": "[email protected]",
    "first_name": "",
    "last_name": ""
}

For route /api/users/auth/logout/ POST

header:
KEY		VALUE
Authorization	Token 6474f20911b0342eb2e5a6afb65f756cf43c9f37
reply:
{
    "detail": "Successfully logged out."
}

For route /api/users/auth/login/ POST

body:
KEY		VALUE
email		[email protected]
password	password321
reply:
{
    "key": "6474f20911b0342eb2e5a6afb65f756cf43c9f37"
}

Playlist example requests

Get all Playlists: URL = "http://127.0.0.1:8000/api/playlist" r = requests.get(url = URL) data = r.json()

Return (Example for 2 playlists):
	[{"id": 1, "name": "coolPlaylist", "rating_sum": 5, "rating_number": 1, "user": 1}, {"id": 2, "name": "coolPlaylist2", "rating_sum": 4, "rating_number": 2, "user": 1}]

Get playlist with id = 1: URL = "http://127.0.0.1:8000/api/playlist/1" r = requests.get(url = URL) data = r.json()

Return:
	{'id': 13, 'name': 'cool2', 'rating_sum': 5, 'rating_number': 1, 'user': 1}

Post new Playlist: URL = "http://127.0.0.1:8000/api/playlist" data = {'user': 1, 'name':'coolPlaylistName', 'rating_sum':6, 'rating_number':2} r = requests.post(url = URL, json = data)

Delete all Playlists: URL = "http://127.0.0.1:8000/api/playlist" r = requests.delete(URL)

Delete playlist with id = 1: URL = "http://127.0.0.1:8000/api/playlist/1" r = requests.delete(url = URL)

Put playlist at id = 1: URL = "http://127.0.0.1:8000/api/playlist/1" data = {'user': 1, 'name':'coolPlaylistName', 'rating_sum':6, 'rating_number':2} r = requests.put(url = URL, json = data)

Post user:

URL = "http://127.0.0.1:8000/api/user" data = {'firstName': 'Max', 'lastName':'Musterman', 'userName':'testUser', 'email':'[email protected]', 'password': 'test'} r = requests.put(url = URL, json = data)

Get all playlists for user with id = 1: api/user/playlists/1

Get playlist rating for user.id = 1 and playlist.id = 2: api/playlist_rating/2/1

Rate a playlist: URL = "http://127.0.0.1:8000/api/rate_playlist" data = {"user": 1, "playlist": 4, "rating": 5}

r = requests.post(url = URL, json=data) (you can always use a Post request, if the rating is already created it will be changed and if it is not created it will be created)

Get/Delete all comments for playlist with id = 1: api/playlist/comments/1

Get/Delete/Post one comment with id = 1: api/comment/1

Get/Delete all comments: api/comment

Put new comment: URL = "http://127.0.0.1:8000/api/comment" data = {"user": 1, "playlist": 4, "comment_text": 'a cool text'}

r = requests.put(url = URL, json=data)

New User model:

For route /api/users/rest/register POST

body:
KEY		VALUE
email		[email protected]
username	hirsch11
first_name	max
last_name	mustermann
password	password321
password2	password321
reply:
{
    "response": "successfully registered new user.",
    "email": "[email protected]",
    "username": "hirsch11",
    "first_name": "max",
    "last_name": "mustermann",
    "pk": 10,
    "token": "9a0f3ecbd826ea2eca3fb72ddec91d3f52f97009"
}

For route /api/users/rest/login POST

body:
KEY		VALUE
email		[email protected]
username	hirsch11
first_name	max
last_name	mustermann
password	password321
password2	password321
reply:
{
    "response": "Successfully authenticated.",
    "pk": 10,
    "email": "[email protected]",
    "token": "9a0f3ecbd826ea2eca3fb72ddec91d3f52f97009"
}

For route /api/users/rest/check_if_account_exists GET

Params:
KEY		VALUE
email		[email protected]
reply:
{
    "response": "[email protected]"
}
# If account does not exist: "response": "Account does not exist"
# alternative params into address: http://127.0.0.1:8000/api/users/rest/check_if_account_exists/[email protected]

For route /api/users/rest/properties GET

Headers:
KEY		VALUE
Authorization	Token 9a0f3ecbd826ea2eca3fb72ddec91d3f52f97009
reply:
{
    "pk": 10,
    "email": "[email protected]",
    "username": "hirsch11",
    "first_name": "max",
    "last_name": "mustermann"
}

For route /api/users/rest/properties/update PUT

Headers:
KEY		VALUE
Authorization	Token 9a0f3ecbd826ea2eca3fb72ddec91d3f52f97009
Body:
KEY		VALUE
username	sheep12
first_name	dieter
last_name	missing
email		[email protected]
reply:
{
    "response": "Account update success"
}

For route /api/users/rest/change_password PATCH

Headers:
KEY		VALUE
Authorization	Token 9a0f3ecbd826ea2eca3fb72ddec91d3f52f97009
Body:
KEY			VALUE
old_password		password321
new_password		password123
confirm_new_password	password123
reply:
{"response":"successfully changed password"}

http://127.0.0.1:8000/api/users/rest/logout POST

Headers:
KEY		VALUE
Authorization	Token 9a0f3ecbd826ea2eca3fb72ddec91d3f52f97009
reply:
{"sheep12 got logged out"}

How to run?

For backend server

cd backend/
pipenv install
pipenv shell
python manage.py runserver

For frontend server

cd frontend/
npm install
npm start

In order for the application to work you have to have both servers running.

groovytunes's People

Contributors

flixirr avatar salach-malejkum avatar mandziuk-mr avatar teletubble avatar hendrikmeininger avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.