Skip to content

cartosat/Flask-API-with-SQLAlchemy

Repository files navigation

RESTful APIs for CRUD, file upload and JWT token based Authentication using Flask and SqlAlchemy ORM

Flask_SqlAlchemy_APIs is a backend application which serve API's for basic CRUD operation, uploading file and JWT token based user authentication. It is built using most lightweight framework flask and one of popular Object Relation Mapper SqlAlchemy. I have used mysql as database in this app.

High Level Diagram:-

Flask_SqlAlchemyHLD

Technology Stack

  • Python
  • Flask
  • SqlAlchemy
  • Postman

We have APIs for :-

  1. Add Admin.
  2. Get information for all Admins in database.
  3. Get information for admin with specific id.
  4. Update Admin Information.
  5. Delete Admin from Database.
  6. Upload file.
  7. User Authentication using JWT token.

Application logs for all 5 operations :-

App Log

Screenshots of Postman tool:-

1) Add Admin :-

  • We need to send POST request through postman and provide payload in Body section.
{
    "email": "sakangupt@gmail.com",
    "phone": " 7788990011",
    "full_name": "Sakshi Gupta",
    "password" : "Pass@123",
    "role": "Admin",
    "status": "Active"
}
  • Image :- add_Admin

2) Get information for all Admins in database.

3. Get information for admin with specific id.

4. Update Admin Information.

{
    "full_name": "Swaraj Gore",
    "email": "swarajgo@gmail.com",
    "password" : "Pass@1234",
    "phone": "49857243857",
    "role": "Admin",
    "status": "Active"
}
  • Image for reference :- update_admin

5. Delete Admin from Database.

6. Upload file

  • This will be POST request and in postman under body section pass appropriate parameters as shown in below image.
  • Example :- http://127.0.0.1:5000/upload_file .
  • Image for reference :- upload_file

7. User Authentication using JWT token.

  • In this case we will perform two operations:-
    • Getting JWT token.
    • View all admins list with token.

A. Getting JWT token.

  • This will be POST request and in postman under body section pass credential payload as shown in below image.
  • Example :- http://127.0.0.1:5000/admin_login .
  • Image :- get_jwt_token
  • Now you got JWT token by calling this endpoint.

B. View all admins list with token.

  • This will be get request, But you need to provide Bearer token in Authorization section. Which you got from above step.
  • Example :- http://127.0.0.1:5000/all_admin .
  • Image :- all_admin_with_token
  • You will get JSON data of all admin, if everything goes well.

How to start Backend server

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages