Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
First Endpoint, Flask-Migration and SQLite Studio | Endpoints with Blueprints and MethodView
course content

Course Content

Professional Web API with Flask

First Endpoint, Flask-Migration and SQLite StudioFirst Endpoint, Flask-Migration and SQLite Studio

Implementing the Club Endpoint

Let's define our first functionality for the Club GET endpoint. We return a ClubModel.query.get_or_404() using ORM, passing the club_id. This simplifies the development process by avoiding raw SQL queries. We import our model from the respective module.

Combining Methods and Schemas

We also need to link our method to the schema we created for data serialization and validation. We use the @blp.response() decorator to return a 200 status code for successful request processing and import ClubSchema from our schemas module.

Migrations

From our previous project, we're familiar with migrations and the Flask-Migrate library. We install Flask-Migrate using:

Initializing Migrations and Database Connection

We need to initialize migrations and link our application to the database. In the app.py file, we import Migrate from the flask_migrate library.

At the end of our file, we initialize a new migrate variable to connect our application (app) and the database (db).

Creating Migration Folders

We're ready to create a folder for our future migrations using the flask db init command. A new folder named migrations appears, containing several files and a versions subfolder.

Using SQLite Studio

Please follow the video to quickly and practically learn how to use the SQLite Studio app.

In the next chapters, we'll explore additional documentation features and testing capabilities for our API and continue defining functionalities for all models.

Everything was clear?

Section 4. Chapter 3
course content

Course Content

Professional Web API with Flask

First Endpoint, Flask-Migration and SQLite StudioFirst Endpoint, Flask-Migration and SQLite Studio

Implementing the Club Endpoint

Let's define our first functionality for the Club GET endpoint. We return a ClubModel.query.get_or_404() using ORM, passing the club_id. This simplifies the development process by avoiding raw SQL queries. We import our model from the respective module.

Combining Methods and Schemas

We also need to link our method to the schema we created for data serialization and validation. We use the @blp.response() decorator to return a 200 status code for successful request processing and import ClubSchema from our schemas module.

Migrations

From our previous project, we're familiar with migrations and the Flask-Migrate library. We install Flask-Migrate using:

Initializing Migrations and Database Connection

We need to initialize migrations and link our application to the database. In the app.py file, we import Migrate from the flask_migrate library.

At the end of our file, we initialize a new migrate variable to connect our application (app) and the database (db).

Creating Migration Folders

We're ready to create a folder for our future migrations using the flask db init command. A new folder named migrations appears, containing several files and a versions subfolder.

Using SQLite Studio

Please follow the video to quickly and practically learn how to use the SQLite Studio app.

In the next chapters, we'll explore additional documentation features and testing capabilities for our API and continue defining functionalities for all models.

Everything was clear?

Section 4. Chapter 3
some-alt