Flask By Example

 
 
Packt Publishing Limited
  • 1. Auflage
  • |
  • erschienen am 31. März 2016
  • |
  • 276 Seiten
 
E-Book | ePUB mit Adobe DRM | Systemvoraussetzungen
978-1-78528-348-2 (ISBN)
 
Unleash the full potential of the Flask web framework by creating simple yet powerful web applicationsAbout This BookThe most up-to-date book on Flask on the marketCreate your own world-class applications and master the art of Flask by unravelling its enigma through this journeyThis step-by-step tutorial is packed with examples on blending different technologies with Flask to get you up and runningWho This Book Is ForHave 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 LearnBuild three web applications from the ground up using the powerful Python micro framework, Flask.Dynamically display data to your viewers, based on their requestsStore user and static data in SQL and NoSQL databases and use this data to power your web applicationsCreate a good user experience by combining HTML, CSS, and JavaScriptHarness the convenience of freely available APIs, including OpenWeatherMap, Open Exchange Rates, and bitlyExtend your applications to build advanced functionality, such as a user account control system using Flask-LoginLearn about web application security and defend against common attacks, such as SQL injection and XSSIn DetailThis 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.
  • Englisch
  • Birmingham
978-1-78528-348-2 (9781785283482)
1785283480 (1785283480)
weitere Ausgaben werden ermittelt
  • Cover
  • Copyright
  • Credits
  • About the Author
  • Acknowledgements
  • About the Reviewers
  • www.PacktPub.com
  • Table of Contents
  • Preface
  • Chapter 1: Hello, World!
  • Introducing Flask
  • Creating our development environment
  • Installing pip
  • Installing Flask
  • Writing "Hello, World!"
  • Writing the code
  • Running the code
  • Deploying our application to production
  • Setting up a Virtual Private Server
  • Configuring our server
  • Installing and using Git
  • Serving our Flask app with WSGI
  • Configuring Apache to serve our Flask application
  • Summary
  • Chapter 2: Getting Started with Our Headlines Project
  • Setting up our project and a Git repository
  • Creating a new Flask application
  • Introduction to RSS and RSS feeds
  • Using RSS from Python
  • URL routing in Flask
  • Publishing our Headlines application
  • Summary
  • Chapter 3: Using Templates in Our Headlines Project
  • Introducing Jinja
  • Basic use of Jinja templates
  • Rendering a basic template
  • Passing dynamic data to our template
  • Displaying dynamic data in our template
  • Advanced use of Jinja templates
  • Using Jinja objects
  • Adding looping logic to our template
  • Adding hyperlinks to our template
  • Pushing our code to the server
  • Summary
  • Chapter 4: User Input for Our Headlines Project
  • Getting user input using HTTP GET
  • Getting user input using HTTP POST
  • Creating a branch in Git
  • Adding POST routes in Flask
  • Making our HTML form use POST
  • Reverting our Git repository
  • Adding weather and currency data
  • Introducing the OpenWeatherMap API
  • Signing up with OpenWeatherMap
  • 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
  • Adding another search box to our template
  • Using the user's city search in our Python code
  • 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
  • Chapter 5: Improving the User Experience of Our Headlines Project
  • Adding cookies to our Headlines application
  • Using cookies with Flask
  • Setting cookies in Flask
  • Retrieving cookies in Flask
  • Adding CSS to our Headlines application
  • External, internal, and inline CSS
  • Adding our first CSS
  • Adding padding to our CSS
  • Adding more styles to our CSS
  • Adding the div tags to the template file
  • Styling our inputs
  • Summary
  • Chapter 6: Building an Interactive Crime Map
  • Setting up a new Git repository
  • Understanding relational databases
  • Installing and configuring MySQL on our VPS
  • Installing MySQL on our VPS
  • Installing Python drivers for MySQL
  • Creating our Crime Map database in MySQL
  • Creating a database setup script
  • Creating the database
  • Looking at our table columns
  • Indexing and committing
  • Using the database setup script
  • Adding credentials to our setup script
  • Running our database setup script
  • Creating a basic database web application
  • Setting up our directory structure
  • Looking at our application code
  • Looking at our SQL code
  • Reading data
  • Inserting data
  • Deleting data
  • Creating our view code
  • Running the code on our VPS
  • Mitigating against SQL injection
  • Injecting SQL into our database application
  • Mitigating against SQL injection
  • Summary
  • Chapter 7: Adding Google Maps to Our Crime Map Project
  • Running a database application locally
  • Creating a mock of our database
  • Adding a test flag
  • Writing the mock code
  • Validating our expectations
  • Adding an embedded Google Maps widget to our application
  • Adding the map to our template
  • Introducing JavaScript
  • The body of our HTML code
  • Testing and debugging
  • Making our map interactive
  • Adding markers
  • Using a single marker
  • Adding an input form for new crimes
  • The HTML code for the form
  • Adding external CSS to our web application
  • Creating the CSS file in our directory structure
  • Adding CSS code
  • Configuring Flask to use CSS
  • Viewing the result
  • Publishing the result
  • Linking the form to the backend
  • Setting up the URL to collect POST data
  • Adding the database methods
  • Testing the code on the server
  • Displaying existing crimes on our map
  • Getting data from SQL
  • Passing the data to our template
  • Using the data in our template
  • Viewing the results
  • Summary
  • Chapter 8: Validating User Input in Our Crime Map Project
  • Choosing where to validate
  • Identifying inputs that require validation
  • Trying out an XSS example
  • The potential of persistent XSS
  • Validating and sanitizing
  • White and blacklisting
  • Validating versus sanitizing
  • Implementing validation
  • Validating the category
  • Validating the location
  • Validating the date
  • Validating the description
  • Summary
  • Chapter 9: Building a Waiter Caller App
  • Setting up a new git repository
  • Setting up the new project locally
  • Setting up the project on our VPS
  • Using Bootstrap to kick-start our application
  • Introducing Bootstrap
  • Downloading Bootstrap
  • Bootstrap templates
  • Adding user account control to our application
  • Introducing Flask-Login
  • Installing and importing Flask-Login
  • Using Flask extensions
  • Adding a restricted route
  • Authenticating a user
  • Creating a user class
  • Mocking our database for users
  • Logging in a user
  • Adding imports and configuration
  • Adding the login functionality
  • Checking the login functionality
  • Logging out a user
  • Registering a user
  • Managing passwords with cryptographic hashes
  • Implementing secure password storage in Python
  • Summary
  • Chapter 10: Template Inheritance and WTForms in Waiter Caller Project
  • Adding the Account and Dashboard pages
  • Introducing Jinja templates
  • Creating the base template
  • Creating the dashboard template
  • Creating the account template
  • Creating the home template
  • Adding the routing code
  • Creating restaurant tables
  • Writing the restaurant table code
  • Testing the restaurant table code
  • Shortening URLs using the bitly API
  • Introducing Bitly
  • Using the bitly API
  • Getting a bitly oauth token
  • Creating the bitlyhelper file
  • Using the bitly module
  • 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
  • Adding user feedback with WTForms
  • Introducing WTForms
  • Installing Flask-WTF
  • Creating the registration form
  • Rendering the registration form
  • Updating the application code
  • Updating the template code
  • Testing the new form
  • Using WTForms in our application code
  • Displaying errors to our user
  • Testing the final registration form
  • Adding a successful registration notification
  • Modifying the login form
  • Creating the new LoginForm in the application code
  • Using the new LoginForm in the template
  • Modifying the create table form
  • Summary
  • Chapter 11: Using MongoDB with Our Waiter Caller Project
  • Introducing MongoDB
  • Installing MongoDB
  • Using the MongoDB shell
  • Starting the MongoDB shell
  • Running commands in the MongoDB shell
  • Creating data with MongoDB
  • Reading data with MongoDB
  • Updating data with MongoDB
  • Deleting data with MongoDB
  • Introducing PyMongo
  • Writing the DBHelper class
  • Adding the user methods
  • Adding the table methods
  • Adding the request methods
  • Changing the application code
  • Testing our application in production
  • Adding some finishing touches
  • Adding indices to MongoDB
  • Where do we add indices?
  • Adding a favicon
  • Summary
  • Appendix: A Sneak Peek into the Future
  • Expanding the projects
  • Adding a domain name
  • Adding HTTPS
  • E-mail confirmation for new registrations
  • Google Analytics
  • Scalability
  • Expanding your Flask knowledge
  • VirtualEnv
  • Flask Blueprints
  • Flask extensions
  • Flask-SQLAlchemy
  • Flask MongoDB extensions
  • Flask-MongoEngine
  • Flask-Mail
  • Flask-Security
  • Other Flask extensions
  • Expanding your web development knowledge
  • Summary
  • Index

Dateiformat: EPUB
Kopierschutz: Adobe-DRM (Digital Rights Management)

Systemvoraussetzungen:

Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).

Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions (siehe E-Book Hilfe).

E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)

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.

Weitere Informationen finden Sie in unserer E-Book Hilfe.


Download (sofort verfügbar)

28,05 €
inkl. 19% MwSt.
Download / Einzel-Lizenz
ePUB mit Adobe DRM
siehe Systemvoraussetzungen
E-Book bestellen

Unsere Web-Seiten verwenden Cookies. Mit der Nutzung des WebShops erklären Sie sich damit einverstanden. Mehr Informationen finden Sie in unserem Datenschutzhinweis. Ok