Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Learning Flask Framework
  • Toc
  • feedback
Learning Flask Framework

Learning Flask Framework

4.5 (2)
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
11
Index

Unit testing


Unit Testing is a process that allows us to have confidence in the code, confidence in bug fixes, and confidence in future features. The idea of unit testing is simple; you write code that complements your functional code.

As an example, let's say we design a program that needs to calculate some math correctly; how do you know it's successful? Why not pull out a calculator, and you know what a computer is? A big calculator. Also, computers are really quite good at mundane repetitive tasks, so why not write a unit test that works out the answer for you? Repeat this pattern for all areas of your code, bundle those tests up into one wrapper, and you have complete confidence in the code that you have produced.

Note

There are some who say that tests are a sign of code "smell", that your code is so complex that it needs tests to prove that it works. This means that the code should be simpler. However, it really depends on your situation and it is up to you to make that judgment call...

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