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

Implementing error-handling solutions

Chapter 1 showcased the use of the redirect() method in rendering error pages given a status code, such as the status code 500. We will now discuss a better way of managing exceptions and status codes, including triggering error pages per status code.

Flask applications must always implement an error-handling mechanism using any of the following strategies:

  • Registers a custom error function using the app’s register_error_handler() method.
  • Creates an error handler using the app’s errorhandler decorator.
  • Throws a custom Exception class.

Using the register_error_handler method

The declarative way to implement an error handler is to create a custom function and register it to the app’s register_error_handler() method. The custom function must have a single local parameter that will accept the injected error message from the platform. It must also return its assigned error page using the make_response...

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