https://fynd-intv.herokuapp.com/
heroku logs --tail --app fynd-intv
heroku ps:scale web=1 --app fynd-intv
https://fynd-intv.herokuapp.com/
RESTful API that add users and movies
- Models/ ("models": objects, functions which connect to database, function as data abstraction layer)
- Tests/ (tests repository)
- Routes/ ("views": implementation of API validation, RESTful & json responses)
- main.py (main application, route setting)
- requirements.txt (Pythonic requirements)
Install requirements by:
pip install -r requirements.txt
Prerequisites:
- RUN
run.pyto run server
-
GET
https://fynd-intv.herokuapp.com/users[{"id": 1, "name": "amichay"}]
```
`GET https://fynd-intv.herokuapp.com/users`
```
[{'id': 1, "name: 'amichay}]
```
-
login is done by POST to
/authwith payload that includes username & password. The login endpoint returns JWT access-token (which is short-lived) and refresh-token used for getting a new access-token. -
Example response payload:
{'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0OCwiZXhwIjoxNTU5NjQ3MTI1LCJpYXQiOjE1NTk2NDUzMjUsIm5hbWUiOiJBbWljaGF5IE9yZW4iLCJlbWFpbCI6ImFtaWNoYXkub3Jlbis0Mzc4QGdtYWlsLmNvbSIsInNjb3BlcyI6WyJ1c2VyIl19.2arsjawnHlPT0StNxTkyO6kEdDImqgCnFPjVbcRidEs', 'refresh_token': '12a6c653839e03be9cfa56d35eed26931668b174a58bb589'} -
access_tokenshould be used in the header for all protected calls as follows:headers = {"Authorization": f"Bearer {access_token}"} -
GET
/auth/verifyvalidates the access-token and responds with{'valid': True} -
GET
/auth/mereturns the user information attached to the token. -
GET
/auth/refreshreturns a new access-token. Keep in mind that the fresh-token is not expired in this basic implementation. -
An example of The JWT claims include:
{ "user_id": 48, "exp": 1559647125, "iat": 1559645325, "name": "Amichay Oren", "username": "amichay.oren+4378@gmail.com", }- Be advised that the scope is presented, however scope is validated against what appears in the user_id database, and not what is passed in the scope. This means that if user scopes are changed, while they might not be reflected in the JWT claims (yet) they would still impact the authorization.
-
Failure to authorize access to resource will return HTTP 403.
-
POST
/registerto register user{ "name": "gilu", "username": "gilu@ggmail.com", "password": "Test@123" }{ "User created successfully": "User 1: gilu@ggmail.com" } -
POST
/update_user/<user_id>update user information (only for admin role with token authentication).{ "name": "Test", "email": "Test@test.com" } -
DELETE
/users/<user_id>deactivate user information (only for admin role with token authentication).
-
Movies API with authentication and endpoints
-
POST
/uploadto upload movies data through file (only for admin role with token authentication)file upload -
POST
/search_movies?pk=1search movie with params (only for admin role with token authentication).[{"movie_name": "The Wizard of Oz", "popularity": 83.0, "imdbScore": 8.3, "year_release": "2017", "genre__genre_name": ["Adventure", " Family", " Fantasy", " Musical"], "director": "Victor Fleming"}] -
POST
/search_moviessearch movie with arguments (only for admin role with token authentication).{ "movie_name": "The Wizard of Oz", "popularity": 9, "imdbScore": 8.3, "director": "Victor Fleming" }[ { "movie_name": "The Wizard of Oz", "popularity": 83.0, "imdbScore": 8.3, "year_release": "2017", "genre_name": [ "Adventure", " Family", " Fantasy", " Musical" ], "director": "Victor Fleming" }, { "movie_name": "James Bond", "popularity": 9.0, "imdbScore": 9.0, "year_release": "2010", "genre_name": [ "Action", " Adventure", " Fantasy", " Sci-Fi", "Action" ], "director": "Ian Filming" }, { "movie_name": "Skyfall", "popularity": 9.0, "imdbScore": 9.0, "year_release": "2010", "genre_name": [ "Action", " Adventure", " Fantasy", " Sci-Fi", "Action" ], "director": "Ian Filming" } ]OR
{ "genre": ["Adventure", "Family"] }{ "response": [ { "movie_name": "Star Wars", "popularity": 88.0, "imdbScore": 8.8, "year_release": "2010", "genre_name": [ "Action", " Adventure", " Fantasy", " Sci-Fi" ], "director": "George Lucas" }, { "movie_name": "Casablanca", "popularity": 88.0, "imdbScore": 8.8, "year_release": "2017", "genre_name": [ "Drama", " Romance", " War" ], "director": "Michael Curtiz" } ] } -
POST
/add_moviesadd movies (only for admin role with token authentication).{ "movie_name": "Test movie", "popularity": 9, "imdbScore": 8.3, "genre": ["Action"], "director": "Test" } -
POST
/update_moviesupdate movies (only for admin role with token authentication).{ "id": 109, "movie_name": "Test movie changed", "popularity": 9, "imdbScore": 8.3, "genre": ["Action"], "director": "Test" }
- email nadivo1208@elastit.com
- pass Redmi@007