Packt.Mastering.Flask.Web.Development.2nd.Edition

所需积分/C币:16 2019-01-14 09:14:16 7.8MB PDF
44
收藏 收藏
举报

Packt.Mastering.Flask.Web.Development.2nd.Edition
Mastering Flask Web Development Second Edition Copyright o 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information Commissioning Editor: Amarabha Banerjee Acquisition Editor: Devanshi doshi Content Development Editor: Onkar Wani Technical Editor: Diksha Wakde Copy Editor: Safis Editing Project Coordinator: Sheejal Shah Proofreader: Safis Editing Indexer: Rekha nair Graphics: Alishon Mendonsa Production Coordinator: Aparna Bhagat First published: September 2015 Second Edition: October 2018 Production reference: 1301018 Published by packt Publishing ltd 35 Livery street Birmingham B3 2PB, UK ISBN978-1-78899-540-5 www.pAcktpub.com GET OFF ANY PACKT EBOOK AND VIDEO Python Deep Flask Web Pyth。n Learning Development Automation Gotowww.packtpub.com and use this code in the checkout HBBI8OOFF Packt> Mapt mapt.lO Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website Why subscribe? Spend less time learning and more time coding with practical ebooks and videos from over 4, 000 industry professionals Improve your learning with Skill Plans built especially for you Get a free ebook or video every month e Mapt is fully searchable Copy and paste, print, and bookmark content Packt. com Did you know that Packt offers eBook versions of every book published, with PDF and epubfilesavailableYoucanupgradetotheebookversionatwww.packt.comandasaprint book customer, you are entitled to a discount on the e Book copy. Get in touch with us at customercare@packtpub com for more details Atwww.packt.comyoucanalsoreadacollectionoffreetechnicalarticlessignupfora range of free newsletters and receive exclusive discounts and offers on packt books and eBookS Contributors About the authors Daniel Gaspar is a programmer and DevOps engineer with more than 20 years'experience He has worked in a wide range of sectors, including government and finance. He is tools in his daily work, but Flask caught his attention because of its excellently designer Of currently working at Miniclip(the global leader in digital games). He uses a wide range API and simplicity. Daniel is an OSS and Python enthusiast, and has developed a widely used extension/framework named Flask-AppBuilder used by airbnb on Superset and Airflow First, I would like to thank my wife, Susana, and my beautiful children, Mariana and Pedro, for their amazing support, enthusiasm, and patience. Also, a big thank you to everyone at Packt Publishing, especially to Onkar Wani, with whom it was a pleasure to rk Jack Stouffer is a programmer who has several years of experience in designing web applications. He switched to Flask two years ago for all his projects. He currently works for Apollo America in Auburn Hills, Michigan and writes internal business tools and software using Python, Flask, and JavaScript. Jack is a believer and supporter of open source technology when he released his flask examples with the recommended best practices on GitHub, it became one of the most popular Flask repositories on the site. Jack has also worked as a reviewer for Flask framework Cookbook, packt About the reviewer Damyan Bogoev is based in Bulgaria, where he currently works at gtmhub as a software engineer. Prior to Gtmhub, Damyan worked at Telerik His background is in developing backend server applications and tools for infrastructure automation, management, and monitoring Damyan is also technical reviewer for the Web aPI Development with flask video course Packt is searching for authors like you IfyoureinterestedinbecominganauthorforPackt,pleasevisitauthorspacktpub.com and apply today We have worked with thousands of developers and tech professionals just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea Table of contents Preface Chapter 1: Getting Started 6 Version control with git Installing git Git on windows Git basics 7777 Git branches and flow Python package management with pip 15 stalling the Python package manager on Windows 15 Installing pip Python package manager on macOS X and Linux 16 Pip basics Dependency sandboxing with virtualenv 18 Virtualeny basics 19 Setting up Docker 19 The beginning of our project Simple application 21 Project structure 22 Using Flask's command-line interface 22 Summa 23 Chapter 2: Creating Models with SQLAlchemy 24 Setting up SQLAlchemy 25 Python packages 25 Flask SQLAlchemy 26 Our first model Creating the user table CRUD 30 Creating models Reading models Filtering queries 32 Updating models 34 Deleting models 34 Relationships between models 34 One-to-many relationship 35 Many-to-many relationship 38 Constraints and indexing 40 Database migrations with Ale mbic essions The convenience of sQlalchemy s 42 43 Summar 46 Table of contents Chapter 3: Creating Views with Templates 47 Jinja's syntax 47 Filters 48 The default filter The escape filter 49 The float filter 49 The int filter 49 The join filter 50 The length filter 50 The round filter 50 The safe filter The title filter The towson filter 555 The truncate filter 52 Custom filters 52 Comments 53 Using if statements 53 Loops 53 Macros 55 Flask-specific variables and functions 55 The config object 56 The request object The session object 56 The url for( function The get flashed_messages( function 57 Creating our views The view function 55 88 Writing the templates and inheritance 60 The base template 61 The child templates 64 Writing the other templates 67 Flask Wtforms 68 WTForms basics 69 Custom validations Posting comments 71 Summary 74 Chapter 4: Creating Controllers with Blueprints Sessions and globals 75 Request setup and teardown 76 Error pages 77 Class-based views 78 Method class views 81 Blueprints 81 Summary 84 Chapter 5: Advanced Application Structure 85 Table of contents Modular application 85 Refactoring the code 87 Application factories 89 Summary 91 Chapter 6: Securing Your App 92 Authentication methods 93 Basic authentication 93 Remote-user authentication 94 LDAP authentication 95 Database user model authentication 97 OpenId and oauth 97 Flask-Login overview 100 Setting up 101 Updating the models 103 Creating the forms 106 Protecting your form from spam 107 Creating views 109 OpenID 114 OAuth 117 Role-based access control(RBAC) 119 Summary 122 Chapter 7: Using NosQL with Flask 123 Types of nosQl database 124 Key-value stores 124 Document stores 125 Column family stores 125 Graph databases 128 RDBMS versus NoSQL 129 The strengths of RDBMS databases 129 Data integrity 130 Speed and scale 130 131 The strengths of NosQL databases 131 CAP theorem 132 What database to use and when 135 Mongo dB in Flask 136 Installing MongoDB 136 Setting up MongoEngine 137 Defining documents 138 Field types 139 Types of documents 141 The meta attribute 141 CRUD 143 Create 143

...展开详情
试读 127P Packt.Mastering.Flask.Web.Development.2nd.Edition
立即下载
限时抽奖 低至0.43元/次
身份认证后 购VIP低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 分享王者

关注 私信
上传资源赚钱or赚积分
最新推荐
Packt.Mastering.Flask.Web.Development.2nd.Edition 16积分/C币 立即下载
1/127
Packt.Mastering.Flask.Web.Development.2nd.Edition第1页
Packt.Mastering.Flask.Web.Development.2nd.Edition第2页
Packt.Mastering.Flask.Web.Development.2nd.Edition第3页
Packt.Mastering.Flask.Web.Development.2nd.Edition第4页
Packt.Mastering.Flask.Web.Development.2nd.Edition第5页
Packt.Mastering.Flask.Web.Development.2nd.Edition第6页
Packt.Mastering.Flask.Web.Development.2nd.Edition第7页
Packt.Mastering.Flask.Web.Development.2nd.Edition第8页
Packt.Mastering.Flask.Web.Development.2nd.Edition第9页
Packt.Mastering.Flask.Web.Development.2nd.Edition第10页
Packt.Mastering.Flask.Web.Development.2nd.Edition第11页
Packt.Mastering.Flask.Web.Development.2nd.Edition第12页
Packt.Mastering.Flask.Web.Development.2nd.Edition第13页
Packt.Mastering.Flask.Web.Development.2nd.Edition第14页
Packt.Mastering.Flask.Web.Development.2nd.Edition第15页
Packt.Mastering.Flask.Web.Development.2nd.Edition第16页
Packt.Mastering.Flask.Web.Development.2nd.Edition第17页
Packt.Mastering.Flask.Web.Development.2nd.Edition第18页
Packt.Mastering.Flask.Web.Development.2nd.Edition第19页
Packt.Mastering.Flask.Web.Development.2nd.Edition第20页

试读结束, 可继续阅读

16积分/C币 立即下载