Book description
Unleash the full potential of the Flask web framework by creating simple yet powerful web applications
About This Book
- The most up-to-date book on Flask on the market
- Create your own world-class applications and master the art of Flask by unravelling its enigma through this journey
- This step-by-step tutorial is packed with examples on blending different technologies with Flask to get you up and running
Who This Book Is For
Have you looked at PHP and hated the clunky bloated syntax? Or looked at .Net and wished it was more open and flexible? Maybe you've tried your hand at GUI libraries in Python and found them hard to use? If your answer to any one of these questions is a yes, then this is just the book for you.
It is also intended for people who know the basics of Python and want to learn how to use it to build powerful solutions with a web front-end.
What You Will Learn
- Build three web applications from the ground up using the powerful Python micro framework, Flask.
- Dynamically display data to your viewers, based on their requests
- Store user and static data in SQL and NoSQL databases and use this data to power your web applications
- Create a good user experience by combining HTML, CSS, and JavaScript
- Harness the convenience of freely available APIs, including OpenWeatherMap, Open Exchange Rates, and bitly
- Extend your applications to build advanced functionality, such as a user account control system using Flask-Login
- Learn about web application security and defend against common attacks, such as SQL injection and XSS
In Detail
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.
Style and approach
This book will provide you with rich, practical experience of Flask. Every technology, that is employed along with Flask is comprehensively introduced, while the book focusses on developing web applications. Pointers to educational material are always given if you want to gain in-depth knowledge of the various technologies used.
Table of contents
-
Flask By Example
- Table of Contents
- Flask By Example
- Credits
- About the Author
- Acknowledgements
- About the Reviewers
- www.PacktPub.com
- Preface
- 1. Hello, World!
- 2. Getting Started with Our Headlines Project
- 3. Using Templates in Our Headlines Project
-
4. User Input for Our Headlines Project
- Getting user input using HTTP GET
- Getting user input using HTTP POST
-
Adding weather and currency data
- Introducing the OpenWeatherMap API
- Retrieving your OpenWeatherMap API key
- Parsing JSON with Python
- Introducing JSON
- Retrieving and parsing JSON in Python
- Using our weather code
- Displaying the weather data
- Allowing the user to customize the city
- Checking our new functionality
- Handling duplicate city names
-
Currency
- Getting an API key for the Open Exchange Rates API
- Using the Open Exchange Rates API
- Using our currency function
- Displaying the currency data in our template
- Adding inputs for the user to select currency
- Creating an HTML select drop-down element
- Adding all the currencies to the select input
- Displaying the selected currency in the drop-down input
- Summary
- 5. Improving the User Experience of Our Headlines Project
- 6. Building an Interactive Crime Map
- 7. Adding Google Maps to Our Crime Map Project
- 8. Validating User Input in Our Crime Map Project
-
9. Building a Waiter Caller App
- Setting up a new Git repository
- Using Bootstrap to kick-start our application
- Adding user account control to our application
- Summary
-
10. Template Inheritance and WTForms in Waiter Caller Project
- Adding the Account and Dashboard pages
- Shortening URLs using the bitly API
-
Adding functionality to handle attention requests
-
Writing the attention request code
- Adding the attention request route
- Adding the attention request database code
- Add the get and delete methods for attention requests
- Modifying the dashboard route to use attention requests
- Modifying the template code to display attention requests
- Adding the resolve request application code
- Testing the attention request code
- Auto-refreshing the dashboard page
-
Writing the attention request code
-
Adding user feedback with WTForms
- Introducing WTForms
- Installing Flask-WTF
- Creating the registration form
- Rendering the registration form
- Modifying the login form
- Modifying the create table form
- Summary
- 11. Using MongoDB with Our Waiter Caller Project
- A. A Sneak Peek into the Future
- Index
Product information
- Title: Flask By Example
- Author(s):
- Release date: March 2016
- Publisher(s): Packt Publishing
- ISBN: 9781785286933
You might also like
video
An Introduction to Flask
Get started with Flask, the popular web framework that’s small, lightweight, and powerful. This video tutorial …
book
Mastering Flask
Gain expertise in Flask to create dynamic and powerful web applications About This Book Work with …
book
Flask Blueprints
Dive into the world of the Flask microframework to develop an array of web applications About …
book
Building Web Applications with Flask
Use Python and Flask to build amazing web applications, just the way you want them! Learn …