We are going to design a REST API for performing CRUD operations on our todos model. Our application will have a basic authentication and authorization workflow in order to secure the REST API endpoints.
The following is the scaffolding for our application:
Here, we will have three individual packages called config
, auth
, and todo
under the app
module. We will configure and create the Flask application object in the app
module's init
file. The following is the code snippet of __init__.py
, where we configured the Flask application object with extensions and the config
object.
File—app
/__init__.py
:
from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_jwt import JWT, jwt_required, current_identity from app.config import config db = SQLAlchemy() migrate = Migrate() def create_app(environment): app = Flask(__name__) app.config.from_object(config[environment]) db.init_app(app) migrate.init_app(app...