Schweitzer Fachinformationen
Wenn es um professionelles Wissen geht, ist Schweitzer Fachinformationen wegweisend. Kunden aus Recht und Beratung sowie Unternehmen, öffentliche Verwaltungen und Bibliotheken erhalten komplette Lösungen zum Beschaffen, Verwalten und Nutzen von digitalen und gedruckten Medien.
Flask, the lightweight Python web framework, is popular due to its powerful modular design that lets you build scalable web apps. With this recipe-based guide, you'll explore modern solutions and the best practices to build web applications using Flask.
Updated to the latest version of Flask 2.2.x and Python 3.11.x, this third edition of Flask Framework Cookbook moves away from some of the old and obsolete libraries and introduces recipes on bleeding-edge technologies. You'll discover different ways of using Flask to create, deploy, and manage microservices.
This book takes you through a number of recipes that will help you understand the power of Flask and its extensions. You will start by exploring the different configurations that a Flask application can make use of. From here, you will learn how to work with templates, before learning about the ORM and view layers, which act as the foundation of web applications. Then, you will learn how to write RESTful APIs with Flask, after learning various authentication techniques.
As you move ahead, you will learn how to write an admin interface, followed by debugging and logging errors in Flask. You will also learn how to make your applications multilingual and gain insight into the various testing techniques. You will learn about the different deployment and post-deployment techniques on platforms such as Apache, Tornado, NGINX, Gunicorn, Sentry, New Relic, and Datadog. Finally, you will learn about popular microservices tools, such as Docker, Kubernetes, Google Cloud Run, and GitHub Actions, that can be used to build highly scalable services.
A new chapter has been added on the latest technology that is making waves nowadays - that is, GPT. Here, you will learn about some simple and basic yet powerful implementations of GPT to build automated text completion fields, chatbots, and AI-powered image generations. Before you complete the book, you will learn about some additional tips and tricks that will be helpful to handle specific use cases, such as full-text searching, caching, email, and asynchronous operations.
By the end of this book, you will have all the information required to make the best use of this incredible microframework, writing small and big applications and scaling them with industry-standard practices.
If you are a web developer who wants to learn more about developing scalable and production-ready applications in Flask, this is the book for you. You'll also find this book useful even if you are already aware of Flask's major extensions and want to use them for better application development. This book can also come in handy if you quickly want to refer to any specific topic on Flask, any of its popular extensions, or some specific use cases. Basic Python programming experience along with some understanding of web development and its related terminology is assumed.
Chapter 1, Flask Configurations, explains the different ways in which Flask can be configured to suit the various needs of any project. It starts by telling us how to set up a development environment and moves on to the different configuration techniques.
Chapter 2, Templating with Jinja, covers the basics of Jinja2 templating from the perspective of Flask and explains how to make applications with modular and extensible templates.
Chapter 3, Data Modeling in Flask, deals with one of the most important parts of any application - that is, its interaction with database systems. We will see how Flask can connect to different database systems, define models, and query databases to retrieve and feed data.
Chapter 4, Working with Views, deals with the core of web frameworks. It talks about how to interact with web requests and the proper responses to these requests. It covers various methods of handling requests properly and designing them in the best way.
Chapter 5, Web Forms with WTForms, covers form handling, which is an important part of any web application. As much as forms are important, their validation holds equal importance, if not more. Presenting this information to users in an interactive fashion adds a lot of value to an application.
Chapter 6, Authenticating in Flask, talks about authentication, which acts as the red line between an application being secure and insecure. It deals with multiple social and enterprise login techniques in detail. Authentication is an important part of any application, be it web-based, desktop, or mobile.
Chapter 7, RESTful API Building, explains REST as a protocol and then discusses writing RESTful APIs for Flask applications using libraries, as well as completely customized APIs. An API can be summarized as a developer's interface to an application.
Chapter 8, Admin Interface for Flask Apps, focuses on writing admin views for Flask applications. First, we will write completely custom-made views and then write them with the help of an extension. As opposed to the very popular Python-based web framework Django, Flask does not provide an admin interface by default. Although this can be seen as a shortcoming by many, this gives developers the flexibility to create an admin interface as per their requirements and have complete control over an application.
Chapter 9, Internationalization and Localization, expands the scope of Flask applications and covers the basics of how to enable support for multiple languages. Web applications usually are not limited to one geographical region or to serving people from one linguistic domain. For example, a web application intended for users in Europe will be expected to support other European languages, such as German, French, Italian, Spanish, and so on, apart from English.
Chapter 10, Debugging, Error Handling, and Testing, moves on from being completely development-oriented to testing our application. With better error handling and tests, the robustness of the application increases manifold, and debugging makes the lives of developers easier. It is very important to know how robust our application is and to keep track of how it has worked and performed. This, in turn, gives rise to the need to be informed when something goes wrong in the application. Testing in itself is a very huge topic and has several books devoted to it.
Chapter 11, Deployment and Post-Deployment, covers the various ways and tools with which an application can be deployed. Then, you will learn about application monitoring, which helps us to keep track of the performance of the application. Deployment of an application and managing the application post-deployment is as important as developing it. There can be various ways of deploying an application, and choosing the best way depends on the requirements.
Chapter 12, Microservices and Container, explores how to package Flask applications with Docker and deploy them with Kubernetes. We will also see how to serve applications in a serverless fashion by leveraging Google Cloud Run and GitHub Actions. Microservices is one of the biggest buzzwords in modern software technology. These are as useful as they are popular and make the lives of developers easier. They allows people to focus on development rather than investing that time in thinking about the deployment of applications.
Chapter 13, GPT with Flask, implements some of the most popular and common yet powerful APIs of GPT to build AI-powered apps with Flask. We will see how easy it is to automate text completions using GPT to build highly user-intuitive search fields. Then, a simple chatbot implementation using ChatGPT is demonstrated, followed by AI-powered image generation.
Chapter 14, Additional Tips and Tricks, covers some additional recipes that can be used to add value to an application, if necessary.
You will need Python installed on your computer as a prerequisite. All the code in the book has been written and tested on Python 3.11.x on a UNIX-based OS, either macOS or Ubuntu. The book uses Flask 2.2.x, and not all the code will work for earlier versions of Flask and/or Python. However, most code should work for future versions unless a breaking change is introduced. For other relevant packages or libraries, the versions are mentioned directly in the recipes wherever relevant.
Software/hardware covered in the book
Operating system requirements
Python 3.11.x
Windows, macOS, or...
Dateiformat: ePUBKopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.