Read this before you get started with Flask. This hopefully answers some questions about the purpose and goals of the project, and when you should or should not be using it.
1.1 What does “micro” mean?
"Micro"doesnot mean that vour whole web application has to fit into a single Pvthon file, although it certainly can. Nor does it mean that Flask is lacking in functionality. The"micro"in microframework means Flask aims to keep the core simple but exten- sible. Flask won't make many decisions for you, such as what database to use. Those decisions that it does make, such as what templating engine to use, are easy to change. Everything else is up to you, so that Flask can be everything you need and nothing you don't.
By default, Flask does not include a database abstraction layer, form validation or any- thing else where different libraries already exist that can handle that. Instead, Flask supports extensions to add such functionality to your application as if it was imple- mented in Flask itself. Numerous extensions provide database integration, form val- idation, upload handling, various open authentication technologies, and more. Flask may be"micro", but it's ready for production use on a variety of needs.
1.2 Configuration and Conventions
Flask has many configuration values, with sensible defaults, and a few conventions when getting started. By convention templates and static files are stored in subdirec- tories within the application's Python source tree, with the names templates and static respectively. While this can be changed you usually don't have to, especially when getting started.
1.3 Growing with Flask
Once you have Flaskup and running, you'll find a variety of extensions available in the community to integrate your project for production. The Flask core team reviews extensions and ensures approved extensions do not break with future releases.
As your codebase grows, you are free to make the design decisions appropriate for your project. Flask will continue to provide a very simple glue laver to the best that Python has to offer. You can implement advanced patterns in SQLAlchemy or an- other database tool, introduce non-relational data persistence as appropriate, and take advantage of framework-agnostic tools built for WSGI, the Python web interface.
Flask includes many hooks to customize its behavior. Should you need more cus- tomization, the Flask class is built for subclassing. If you are interested in that, check out the Becoming Big chapter. If you are curious about the Flask design principles, head over to the section about Design Decisions in Flask.
Continue to Installation, the Quickstart, or the Forewoord for Experienced Programmers.
FOREWORD FOR EXPERIENCED
PROGRAMMERS
2.1 Thread-Locals in Flask
One of the design decisions in Flask was that simple tasks should be simple; they should not take a lot of code and yet they should not limit you. Because of that, Flask has few design choices that some people might find surprising or unorthodox.For ex- ample, Flaskuses thread-local objects internally so that you don't have to pass objects around from function to function within a request in order to stay threadsafe. This approach is convenient, but requires a valid request context for dependency injection or when attempting to reuse code which uses a value pegged to the request. The Flask project is honest about thread-locals, does not hide them, and calls out in the code and documentation where they are used.
2.2 Develop for the Web with Caution
Always keep security in mind when building web applications.
If you write a web application, you are probably allowing users to register and leave their data on your server. Theusers are entrusting you with data.And even if you are the only user that might leave data in your application, you still want that data to be stored securely.
Unfortunately, there are many ways the security of a web application can be com- promised. Flask protects you against one of the most common security problems of modern web applications: cross-site scripting (XSS). Unless vou deliberately mark in- secure HTML as secure, Flask and the underlying Jinja2 template engine have you covered. But there are many more ways to cause security problems.
The documentation will warn you about aspects of web development that require at- tention to security. Some of these security concerns are far more complex than one might think, and we all sometimes underestimate the likelihood that a vulnerability will be exploited-until a clever attacker figures out a way to exploit our applications. And don't think that your application is not important enough to attract an attacker.Depending on the kind of attack,chances are that automatedbots are probing for ways to fill your database with spam, links to malicious software, and the like.
Flaskis no different from any other frameworkin that you the developer must build with caution, watching for exploits when building to your requirements.
2.3 The Status of Python 3
Currently the Python community is in the process of improving libraries to support the new iteration of the Python programming language. While the situation is greatly improving there are still some issues that make it hard for users to switch over to Python 3 just now. These problems are partially caused by changes in the language that went unreviewed for too long, partially also because we have not quite worked out how thelower-level API should change to account for the Unicode differences in Python 3.
We strongly recommend using Python 2.6 and 2.7 with activated Python3 warnings during development. If you plan on upgrading to Python 3 in the near future we strongly recommend that you read How to write forwards compatible Python code. If you do want to dive into Python3 already have a look at the python3_support page.
Continue to Installation or the Quickstart.
INSTALLATION
Flask depends on two external libraries, Werkzeug and Jinja2. Werkzeug is a toolkit for WSGI, the standard Python interface between web applications and a variety of servers for both development and deployment. Jinja2 renders templates.
So how do you get all that on your computer quickly? There are many ways you could do that, but the most kick-ass method is virtualenv,so let's have a look at that first.
You will need Python 2.6 or higher to get started, so be sure to have an up-to-date Python 2.xinstallation. For using Flask with Python 3 have a look at Python 3 Support.
3.1 virtualenv
Virtualenv is probably what you want to use during development, and if you have shell access to your production machines, you'll probably want to use it there, too.
What problem does virtualenv solve? If you like Python as much as I do, chances are you want to use it for other projects besides Flask-based web applications. But the more projects you have, the more likely it is that you will be working with different versions of Python itself, or at least different versions of Python libraries. Let's faceit; quite often libraries break backwards compatibility, and it's unlikely that any serious application will have zero dependencies. So what do you do if two or more of your projects have conflicting dependencies?
Virtualenv to the rescue! Virtualenv enables multiple side-by-side installations of Python, one for each project. It doesn't actually install separate copies of Python, but it does provide a clever way to keep different project environments isolated. Let's see how virtualenv works.
If you are on Mac OSXor Linux, chances are that one of the following two commands will work for you:
【download link】
link:https://pan.baidu.com/s/1IH_RdoPiiYOLp0w3c7t5Uw
Extraction code:4pnj
FlashFXP绿色版网盘下载,附激活教程 1926
FlashFxp百度网盘下载链接:https://pan.baidu.com/s/1MBQ5gkZY1TCFY8A7fnZCfQ。FlashFxp是功能强大的FTP工具
Adobe Fireworks CS6 Ansifa绿色精简版网盘下载 1665
firework可以制作精美或是可以闪瞎眼的gif,这在广告领域是需要常用的,还有firework制作下logo,一些原创的图片还是很便捷的,而且fireworks用法简单,配合dw在做网站这一块往往会发挥出很强大的效果。百度网盘下载链接:https://pan.baidu.com/s/1fzIZszfy8VX6VzQBM_bdZQ
navicat for mysql中文绿色版网盘下载 1701
Navicat for Mysql是用于Mysql数据库管理的一款图形化管理软件,非常的便捷和好用,可以方便的增删改查数据库、数据表、字段、支持mysql命令,视图等等。百度网盘下载链接:https://pan.baidu.com/s/1T_tlgxzdQLtDr9TzptoWQw 提取码:y2yq
火车头采集器(旗舰版)绿色版网盘下载 1793
火车头采集器是站长常用的工具,相比于八爪鱼,简洁好用,易于配置。火车头能够轻松的抓取网页内容,并通过自带的工具对内容进行处理。站长圈想要做网站,火车头采集器是必不可少的。百度网盘链接:https://pan.baidu.com/s/1u8wUqS901HgOmucMBBOvEA
Photoshop(CS-2015-2023)绿色中文版软件下载 1916
安装文件清单(共46G)包含Window和Mac OS各个版本的安装包,从cs到cc,从绿色版到破解版,从安装文件激活工具,应有尽有,一次性打包。 Photoshop CC绿色精简版 Photoshop CS6 Mac版 Photoshop CC 2015 32位 Photoshop CC 2015 64位 Photoshop CC 2015 MAC版 Photoshop CC 2017 64位 Adobe Photoshop CC 2018 Adobe_Photoshop_CC_2018 Photoshop CC 2018 Win32 Photoshop CC 2018 Win64