Flask Web Development, 2nd Edition

所需积分/C币:50 2018-04-21 15:00:38 4.02MB PDF

Take full creative control of your web applications with Flask, the Python-based microframework. With the second edition of this hands-on book, you’ll learn Flask from the ground up by developing a complete, real-world application created by author Miguel Grinberg. This refreshed edition accounts fo
3. Templates The Jinja2 Template Engine Rendering Templates Variables Control structures Bootstrap Integration with Flask-Bootstrap Custom Error Pages Links Static Files Localization of dates and times with Flask-Moment 4. Web forms Configuration Form classes HTML Rendering of Forms Form Handling in View Functions Redirects and User sessions Message Flashing 5. Databases SQL Databases NoSQL Databases SQL or NoSQL? Python Database Frameworks Database Management with Flask-SQLAIchemy Model Definition Relationships Database Operations Creating the Tables Inserting Rows Modifying Rows Deleting Rows Querying Rows Database Use in View Functions Integration with the Python Shell Database Migrations with Flask-Migrate Creating a Migration Repository Creating a Migration Scrip Upgrading the Database Adding More Migrations 6. Email Email Support with Flask-Mail Sending Email from the Python Shell Integrating Emails with the Application Sending Asynchronous Email 7. Large Application Structure Project Structure Configuration Options Application Package Using an Application Factory Implementing Application Functionality in a Blueprint Application Script Requirements File Unit Tests Database Setup Running the Application II. EXample: A Social Blogging Application 8. User Authentication Authentication Extensions for Flask Password Security Hashing Passwords with Werkzeug Creating an Authentication Blueprint User Authentication with Flask-Login Preparing the User Model for Logins Protecting Routes Adding a Login Form Signing Users In Signing Users Out Understanding How Flask-Login Works Testing logins New User Registration Adding a User Registration Form Registering New Users Account Confirmation Generating Confirmation Tokens with itsdangerous Sending Confirmation Emails Account Management 9. User roles Database Representation of Roles Role Assignment Role verification 10. User Profiles Profile Information User Profile Page Profile editor User-Level Profile editor Administrator-Level Profile Editor User Avatars 1. Blog Posts Blog Post Submission and Display Blog Posts on Profile Pages Paginating Long Blog Post Lists Creating Fake Blog Post Data Rendering in Pages Adding a Pagination Widget Rich-Text Posts with Markdown and Flask-PageDown Using Flask-PageDown Handling Rich Text on the Server Permanent Links to Blog Posts Blog Post Editor 12. Followers Database Relationships Revisited Many-to-Many Relationships Self-Referential Relationships Advanced Many-to-Many Relationships Followers on the Profile Page Querying Followed Posts Using a Database Join Showing Followed Posts on the Home Page 13. User Comments Database Representation of Comments Comment Submission and Display Comment moderation 14. Application Programming Interfaces Introduction to rest Resources Are Everything Request Methods Request and Response Bodies Versioning RESTfuI Web Services with Flask Creating an API Blueprint Error Handling UserauthenticationwithFlask-httpauth Token-Based Authentication Serializing resources to and from JSON Implementing Resource Endpoints Pagination of Large Resource Collections TEsting Web seRvices with Httpie l. The Last mile 15. Testing Obtaining Code Coverage Reports The Flask Test Client Testing Web Applications Testing Web Services End-to-End Testing with Selenium Is It Worth It? 16. Performance Logging Slow Database Performance Source Code Profiling 17. Deployment Deployment Workflow Logging of Errors During Production Cloud Deployment The Heroku platform Preparing the application Testing with Heroku Local Deploying with git push Deploying an Upgrade Docker Containers Installing Docker Building a Container Image Running a Container Inspecting a Running Container Pushing Your Container Image to an External Registry Using an External Database Container Orchestration with Docker Compose Cleaning Up Old Containers and Images Using Docker in Production Traditional Deployments Server Setup Importing Environment Variables Setting Up Logging 18. Additional resources Using an Integrated Development Environment(IDE) Finding Flask Extensions Getting Help Getting Involved with Flask Index Preface Flask stands out from other frameworks because it lets developers take the drivers seat and have full creative control of their applications. Maybe you have heard the phrase fighting the framework before This happens with most frameworks when you decide to solve a problem with a solution that isnt the official one. It could be that you want to use a different database engine, or maybe a different method of authenticating users. Deviating from the path set by the frameworks developers will give you lots of headaches Flask is not like that. Do you like relational databases? Great. Flask supports them all. Maybe you prefer a NosQl database? No problem at all. Flask works with them too Want to use your own homegrown database engine? Dont need a database at all? Still fine With Flask you can choose the components of your application, or even write your own if that's what you want. No questions asked The key to this freedom is that Flask was designed from the start to be extended. It comes with a robust core that includes the basic functionality that all web applications need and expects the rest to be provided by some of the many third-party extensions in the ecosystem -and, of course, by you In this book I present my workflow for developing web applications with Flask. I don't claim this to be the only true way to build applications with this framework. You should take my choices as recommendations and not as gospel Most software development books provide small and focused code examples that demonstrate the different features of the target technology in isolation, leaving the"glue code that is necessary to transform these different features into a fully working application to be figured out by the reader. I take a completely different approach. All the examples I present are part of a single application that starts out very simple and is expanded in each successive chapter. This application begins life with just a few lines of code and ends as a nicely featured blogging and social networking application Who this book is for You should have some level of Python coding experience to make the most of this book Although the book assumes no previous Flask knowledge, Python concepts such as packages, modules, functions, decorators, and object-oriented programming are assumed to be well understood. Some familiarity with exceptions and diagnosing issues from stack traces will be very useful While working through the examples in this book, you will spend a great deal of time in the command line. You should feel comfortable using the command line of your operating system Modern web applications cannot avoid the use of hTML, Css, and JavaScript. The example application that is developed throughout the book obviously makes use of these but the book itself does not go into a lot of detail regarding these technologies and how they are used. Some degree of familiarity with these languages is recommended if you intend to develop complete applications without the help of a developer versed in client-side techniques I released the companion application to this book as open source on GitHub. Although GitHub makes it possible to download applications as regular ZIP or TAR files, I strongly recommend that you install a git client and familiarize yourself with source code version control (at least with the basic commands to clone and check out the different versions of the application directly from the repository). The short list of commands that you' ll need is shown in"How to Work with the Example code. You will want to use version control for your own projects as well, so use this book as an excuse to learn Git Finally, this book is not a complete and exhaustive reference on the Flask framework. Most features are covered, but you should complement this book with the official Flask documentation How This book Is organized This book is divided into three parts Part I, Introduction to Flask, explores the basics of web application development with the Flask framework and some of its extensions Chapter I describes the installation and setup of the Flask framework. Chapter 2 dives straight into Flask with a basic application Chapter 3 introduces the use of templates in Flask applications e Chapter 4 introduces web forms e Chapter 5 introduces databases e Chapter 6 introduces email support Chapter 7 presents an application structure that is appropriate for medium and large applications Part ll, Example: A Social blogging Application, builds Flasky, the open source blogging and social networking application that I developed for this book e Chapter implements a user authentication system e Chapter 9 implements user roles and permissions e Chapter 10 implements user profile pages e Chapter ll creates the blogging interface Chapter 12 implements followers Chapter 13 implements user comments for blog posts Chapter 14 implements an application programming interface(APD) Part III, The Last Mile, describes some important tasks not directly related to application coding that need to be considered before publishing an application Chapter 15 describes different unit testing strategies in detail Chapter 16 gives an overview of performance analysis techniques

试读 127P Flask Web Development, 2nd Edition

评论 下载该资源后可以进行评论 3

curiousc 不要下载了
xd_zhang_ 的确很垃圾的一个文档
zby0826 根本不是印刷pdf,网页生成的pdf,骗子。

关注 私信 TA的资源

    Flask Web Development, 2nd Edition 50积分/C币 立即下载
    Flask Web Development, 2nd Edition第1页
    Flask Web Development, 2nd Edition第2页
    Flask Web Development, 2nd Edition第3页
    Flask Web Development, 2nd Edition第4页
    Flask Web Development, 2nd Edition第5页
    Flask Web Development, 2nd Edition第6页
    Flask Web Development, 2nd Edition第7页
    Flask Web Development, 2nd Edition第8页
    Flask Web Development, 2nd Edition第9页
    Flask Web Development, 2nd Edition第10页
    Flask Web Development, 2nd Edition第11页
    Flask Web Development, 2nd Edition第12页
    Flask Web Development, 2nd Edition第13页
    Flask Web Development, 2nd Edition第14页
    Flask Web Development, 2nd Edition第15页
    Flask Web Development, 2nd Edition第16页
    Flask Web Development, 2nd Edition第17页
    Flask Web Development, 2nd Edition第18页
    Flask Web Development, 2nd Edition第19页
    Flask Web Development, 2nd Edition第20页


    50积分/C币 立即下载 >