Book Image

Flask By Example

By : Gareth Dwyer
Book Image

Flask By Example

By: Gareth Dwyer

Overview of this book

This book will take you on a journey from learning about web development using Flask to building fully functional web applications. In the first major project, we develop a dynamic Headlines application that displays the latest news headlines along with up-to-date currency and weather information. In project two, we build a Crime Map application that is backed by a MySQL database, allowing users to submit information on and the location of crimes in order to plot danger zones and other crime trends within an area. In the final project, we combine Flask with more modern technologies, such as Twitter's Bootstrap and the NoSQL database MongoDB, to create a Waiter Caller application that allows restaurant patrons to easily call a waiter to their table. This pragmatic tutorial will keep you engaged as you learn the crux of Flask by working on challenging real-world applications.
Table of Contents (20 chapters)
Flask By Example
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

Choosing where to validate


There are a few choices to make when it comes to validating user input and displaying feedback that helps them fix any mistakes they make. The major choice is where to do the validation: in the browser, on the server, or both.

We could do it in JavaScript in the user's browser. The advantages of this approach are that the users will get faster feedback (they don't have to wait to send data to our server, have it validated, and have a response sent back), and it also lightens the load on our server; if we don't use CPU cycles and network bandwidth to validate user data, it means we have lower costs associated with running our server. The disadvantage of this approach is that we have no assurance that the user will not bypass these checks; if the checks are run in the user's browser, then the user has full control over them. This means that data that is validated by client-side checks is still not guaranteed to be what we expect.

We could do it on the server after...