Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Flask Web and API Development
  • Table Of Contents Toc
  • Feedback & Rating feedback
Mastering Flask Web and API Development

Mastering Flask Web and API Development

By : Sherwin John C. Tragura
5 (2)
close
close
Mastering Flask Web and API Development

Mastering Flask Web and API Development

5 (2)
By: Sherwin John C. Tragura

Overview of this book

Flask is a popular Python framework known for its lightweight and modular design. Mastering Flask Web and API Development will take you on an exhaustive tour of the Flask environment and teach you how to build a production-ready application. You’ll start by installing Flask and grasping fundamental concepts, such as MVC and ORM database access. Next, you’ll master structuring applications for scalability through Flask blueprints. As you progress, you’ll explore both SQL and NoSQL databases while creating REST APIs and implementing JWT authentication, and improve your skills in role-based access security, utilizing LDAP, OAuth, OpenID, and databases. The new project structure, managed by context managers, as well as ASGI support, has revolutionized Flask, and you’ll get to grips with these crucial upgrades. You'll also explore out-of-the-box integrations with technologies, such as RabbitMQ, Celery, NoSQL databases, PostgreSQL, and various external modules. The concluding chapters discuss enterprise-related challenges where Flask proves its mettle as a core solution. By the end of this book, you’ll be well-versed with Flask, seeing it not only as a lightweight web and API framework, but also as a potent problem-solving tool in your daily work, addressing integration and enterprise issues alongside Django and FastAPI.
Table of Contents (18 chapters)
close
close
1
Part 1:Learning the Flask 3.x Framework
6
Part 2:Building Advanced Flask 3.x Applications
12
Part 3:Testing, Deploying, and Building Enterprise-Grade Applications

What this book covers

Chapter 1, A Deep Dive into the Flask Framework, introduces Flask as a simple and lightweight Python framework for web applications and showcases the installation of Flask 3 to jumpstart web application development using a non-standard project directory structure with basic Flask features, such as the view functions, class-based views, database connectivity, built-in Werkzeug server and libraries, and custom environment variables.

Chapter 2, Adding Advanced Core Features, provides the Flask 3 core features of web applications, such as session management, data management using Object Relational Mapping (ORM), view rendition using Jinja2 templates, message flashing, error handling, software logging, adding static contents, and applying blueprint and application factory design to project structuring.

Chapter 3, Creating REST Web Services, introduces API development using Flask 3 with request and response handling, implementation of JSON encoders and decoders for parsing the incoming request body and outgoing response, access of request and application context using @before_request and @after_request events, exception handling, and implementation of client applications to consume the REST services.

Chapter 4, Utilizing Flask Extensions, discusses how to save development time and effort by using helpful and efficient Flask modules in replacement to their ground-up equivalents, such as Flask-Session for non-browser-based session handling, Bootstrap-Flask for providing the presentation layer, Flask-WTF for building model-based web forms, Flask-Caching for creating cache, Flask-Mail for sending emails, and Flask-Migrate for building the database schema from data models.

Chapter 5, Building Asynchronous Transactions, explains the asynchronous features of Flask 3, which includes creating asynchronous view and API endpoint functions, implementing an asynchronous repository layer using SQLAlchemy, building asynchronous background tasks using Celery and Redis, implementing WebSocket and Server-Sent Events (SSE) with asyncio utilities, applying asynchronous signals for triggering transactions, and applying reactive programming, and introduces Quart as the ASGI-variant of Flask 3.

Chapter 6, Developing Computational and Scientific Applications, discusses the use of Flask in building scientific applications with XLSX and CSV uploading and tabular and graphical reports using popular Python libraries such as numpy, pandas, matplotlib, seaborn, scipy, and sympy, JavaScript libraries such as Chart.js, Bokeh, and Plotly, LaTeX tools for PDF generation, Celery and Redis for time-expensive background computations, and other scientific tools, such as Julia.

Chapter 7, Using Non-Relational Data Storage, explains how Flask can manage non-relational and big data using popular NoSQL databases, such as Apache HBase/Hadoop, Apache Cassandra, Redis, MongoDB, Couchbase, and Neo4J.

Chapter 8, Building Workflows with Flask, discusses how to implement non-BPMN and BPMN workflows with Flask 3, using Celery and Redis, SpiffWorkflow, Zeebe server from Camunda, Airflow 2, and Temporal.io.

Chapter 9, Securing Flask Applications, provides various ways to secure web-based and API-based Flask applications, such as implementing authentication and authorization mechanisms using HTTP Basic, Digest, and Bearer-token authentication schemes, OAuth2 authorization schemes, and Flask-Login; utilizing encoding/decoding and encryption/decryption libraries to protect user credentials; applying form validation and data sanitation to avoid different web attacks; replacing HTTP with the secured HTTPS to run applications; and controlling response headers to restrict or limit user access.

Chapter 10, Creating Test Cases for Flask, provides techniques for testing with or without mocking the Flask 3 components, such as model classes, repository transactions, native services, view and API endpoint functions, database connectivity, asynchronous processes, and WebSockets, using the PyTest framework.

Chapter 11, Deploying Flask Applications, discusses different options for deploying and running a web or API application, which includes using Gunicorn for standard and asynchronous Flask applications, uWSGI, the Docker platform through Docker Compose and Kubernetes deployments, and Apache HTTP Server.

Chapter 12, Integrating Flask with Other Tools and Frameworks, provides solutions for integrating Flask applications into different popular tools, such as GraphQL, React client applications, and Flutter mobile applications, and for building sub-applications built from Django, FastAPI, Tornado, and Flask frameworks within a microservice application using Flask’s interoperability feature.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY