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 Learning Flask Framework
  • Table Of Contents Toc
  • Feedback & Rating feedback
Learning Flask Framework

Learning Flask Framework

4.5 (2)
close
close
Learning Flask Framework

Learning Flask Framework

4.5 (2)

Overview of this book

Flask is a small and powerful web development framework for Python. It does not presume or force a developer to use a particular tool or library. Flask supports extensions that can add application features as if they were implemented in Flask itself. Flask’s main task is to build web applications quickly and with less code. With its lightweight and efficient web development framework, Flask combines rapid development and clean, simple design. This book will take you through the basics of learning how to apply your knowledge of Python to the web. Starting with the creation of a “Hello world” Flask app, you will be introduced to the most common Flask APIs and Flask’s interactive debugger. You will learn how to store and retrieve blog posts from a relational database using an ORM and also to map URLs to views. Furthermore, you will walk through template blocks, inheritance, file uploads, and static assets. You will learn to authenticate users, build log in/log out functionality, and add an administrative dashboard for the blog. Moving on, you will discover how to make Ajax requests from the template and see how the Mock library can simplify testing complex interactions. Finally, you will learn to deploy Flask applications securely and in an automated, repeatable manner, and explore some of the most popular Flask resources on the web.
Table of Contents (12 chapters)
close
close
11
Index

What this book covers

Chapter 1, Creating Your First Flask Application, begins with the bold declaration, "Flask is fun", which is one of the first things that you see when you view the official Flask documentation, and in this chapter, you will get to grips with why so many Python developers agree.

Chapter 2, Relational Databases with SQLAlchemy, says that relational databases are the bedrock upon which almost all modern web applications are built. We will use SQLAlchemy, a powerful object-relational mapper that allows us to abstract away the complexities of multiple database engines. In this chapter, you will learn about how the data model that you choose early on will affect almost every facet of the code that follows.

Chapter 3, Templates and Views, covers two of the most recognizable components of the framework: the Jinja2 template language, and the URL routing framework. We will fully immerse ourselves in Flask and see our app finally start to take shape. As we progress through the chapter, our app will start looking like a proper website.

Chapter 4, Forms and Validation, shows you how to use forms to modify content on your blog directly through the site handled by the popular WTForms library. This is a fun chapter because we will add all sorts of new ways to interact with our site. We will create forms to work with our data models and learn how to receive and validate user data.

Chapter 5, Authenticating Users, explains how you can add user authentication to your site. Being able to distinguish one user from another allows us to develop an entirely new class of features. For instance, we will see how to restrict access to the create, edit, and delete views, preventing anonymous users from tampering with site content. We can also display a user's draft posts to them but hide them from everyone else.

Chapter 6, Building an Administrative Dashboard, shows you how you can build an administrative dashboard for your site, using the excellent Flask-Admin. Our admin dashboard will give certain selected users the ability to manage all the content across the entire site. In essence, the admin site will be a graphical frontend for the database, supporting operations to create, edit, and delete rows in our application's tables.

Chapter 7, AJAX and RESTful APIs, uses Flask-Restless to create a RESTful API for the blogging app. A RESTful API is a powerful way of accessing your app programmatically by providing highly-structured data to represent it. Flask-Restless works very well with our SQLAlchemy models, and it also handles complex tasks, such as serialization, and result filtering.

Chapter 8, Testing Flask Apps, covers how you can write unit tests covering all parts of the blogging app. We will utilize Flask's test client to simulate "live" requests. We will also see how the Mock library can simplify testing complex interactions, such as calling third-party services, such as databases.

Chapter 9, Excellent Extensions, teaches you how to enhance your Flask installation with popular third-party extensions. We used extensions throughout the book, but we can now explore the added extra security or functionality with very little effort and can polish off your app nicely.

Chapter 10, Deploying Your Application, teaches you how to deploy your Flask applications securely and in an automated, repeatable manner. We will look at how to configure the commonly-used WSGI capable servers, such as Apache and Nginx, as well as the Python web server Gunicorn, to give you plenty of options. Then, we will see how to secure part or the entire site using SSL before finally wrapping up our application in a configuration management tool to automate our deployment.

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 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