Flask is a lightweight web application framework written in Python. Its WSGI toolbox uses Werkzeug and its template engine uses Jinja2. The implementation of many functions refers to the Django framework. Due to the needs of the project, I record the learning process and experience here.
If a worker wants to do his job well, he must first sharpen his tools. Let’s start the flask journey by building a flask development environment.
1. Platform description
Operating system: window 7 64bit Database: mysql5.6 python: v2.7 Development integration software: PyCharm5.0
2. Development environment construction
1. Install flask framework package
1), open the windows command line: pip install flask
E:workdirblog2>pip install flask
Requirement already satisfied: flask in c:python27libsite-packages
Requirement already satisfied: Jinja2>=2.4 in c:python27libsite-packages (from flask)
Requirement already satisfied: Werkzeug>=0.7 in c:python27libsite-packages (from flask)
Requirement already satisfied: click>=2.0 in c:python27libsite-packages (from flask)
Requirement already satisfied: itsdangerous>=0.21 in c:python27libsite-packages (from flask)
Requirement already satisfied: MarkupSafe in c:python27libsite-packages (from Jinja2>=2.4->flask)
2) Verify whether the installation is successful
E:\workdir\blog2>python Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on wi n32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> from flask import Flask >>>
When there is no error when importing the flask package, it means that flask has been installed successfully.
2. Install flask-sqlalchemy package
flask-sqlalchemy What is this? Let’s start with sqlalchemy. SQLAlchemy is an open source software under the Python programming language. Provides SQL toolkit and object-relational mapping (ORM) tools. SQLAlchmey adopts a data mapping model similar to Hibernate in Java. After its release in 2006, it became one of the most widely used ORM tools in the Python community, no less than Django's ORM framework. .
flask-sqlalchemy package is an extension that adds SQLAlchemy support to Flask applications. It requires SQLAlchemy 0.6 or higher. It strives to simplify using SQLAlchemy in Flask, providing useful defaults and additional helpers to make common tasks easier.
1), first install sqlalchemy, open the windows command line: pip install sqlalchemy
E:\workdir\blog2>pip install sqlalchemy
2), then install flask-sqlalchemy
E:\workdir\blog2>pip install flask-sqlalchemy
3) Verify whether flask-sqlalchemy is installed successfully
E:\workdir\blog2>python Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> >>> from flask_sqlalchemy import SQLAlchemy >>> >>>
If there are no errors when importing the package, it means the installation is successful.
At this point, the development environment of flask is completed, and the next article will be practical.
Reference:
快 【Flask Quick Gettingment Chinese Version】 http://docs.jinkan.org/docs/flask/[Flask Quick Start English Version] http://flask.pocoo.org/docs/0.11/
[flask-sqlalchemy Chinese version] http://www.pythondoc.com/flask-sqlalchemy/index.html
[flask-sqlalchemy Chinese version] http://flask-sqlalchemy.pocoo.org/2.1/