Advanced¶
Section 1: Course Preparations¶
Preparations for the course:
- Simplified authentication mechanism.
- Added type hinting.
- Unified code style.
- Changed all
Resourcemethods to class methods (using@classmethod).
Section 2: Marshmallow Integration¶
Introducing marshmallow, flask-marshmallow, and marshmallow-sqlalchemy:
- Simplified request parsing,
Modelobject creation, and JSON responses by definingSchemafor eachResource.
Section 3: Email Verification¶
- Implemented user email verification process (using Mailgun).
- Used
.envfiles to store sensitive data. - Returned
.htmlfiles inFlask-RESTfulusingmake_response()andrender_template().
Section 4: Optimized Email Verification¶
Optimized the email verification process:
- Added expiration for verification and resend functionality.
- Refactored project structure by treating
confirmationas a resource.
Section 6: Secure Configuration and File Uploads¶
- Configured the application more securely (using
from_object()andfrom_envvar()). - Learned the relationships between
WSGI,uwsgi,uWSGI, andWerkzeug. - Introduced
Flask-Uploadsfor handling file uploads, downloads, and deletions (usingUploadSet,FileStorage).
Section 7: Database Version Control¶
- Introduced
Flask-Migratefor database version control, including adding, deleting, and modifying details. - Common commands include
flask db init,flask db upgrade,flask db downgrade.
Section 8: OAuth Integration¶
- Learned OAuth third-party login flow (e.g., GitHub), including authentication, authorization, and obtaining
access_token. - Introduced
Flask-OAuthlib. - Used Flask's
gto storeaccess_token. - Allowed third-party login users to set passwords.
Section 9: Payment Integration¶
- Integrated
Stripefor third-party payment processing. - Added an "Order" resource and implemented many-to-many relationships using
Flask-SQLAlchemy.