Building the development environment for the Flask framework's study guide

  • 2020-05-17 05:51:41
  • OfStack

Flask is a lightweight Web application framework written using Python. Its WSGI toolkit USES Werkzeug, and its templating engine USES Jinja2. Many of the features are implemented using the django framework. Due to the need of the project, the learning process and experience are recorded here.

A workman must sharpen his tools before he can do his work well. Start your flask journey by setting up an flask development environment.

1. Platform description

Operating system: window 7 64bit database: mysql5.6 python: v2.7 development and integration software: PyCharm5.0

2. Build the development environment

1. Install the flask framework package

1) open the command line of windows: pip install flask

E:\workdir\blog2 > pip install flask
Requirement already satisfied: flask in c:\python27\lib\site-packages
Requirement already satisfied: Jinja2 > =2.4 in c:\python27\lib\site-packages (from flask)
Requirement already satisfied: Werkzeug > =0.7 in c:\python27\lib\site-packages (from flask)
Requirement already satisfied: click > =2.0 in c:\python27\lib\site-packages (from flask)
Requirement already satisfied: itsdangerous > =0.21 in c:\python27\lib\site-packages (from flask)
Requirement already satisfied: MarkupSafe in c:\python27\lib\site-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 the flask package is imported without any error, the installation of flask has been successful.

2. Install the flask-sqlalchemy package

flask-sqlalchemy what is this? Let's start with sqlalchemy, which is an open source software of Python programming language. SQL toolkit and object relational mapping (ORM) tools are available. SQLAlchmey, which USES a data mapping model similar to Hibernate in Java, has become one of the most widely used ORM tools in the Python community since its release in 2006, and is no less than Django's ORM framework.

The flask-sqlalchemy package is an extension that adds SQLAlchemy support to Flask applications. It requires SQLAlchemy 0.6 or higher. It aims to simplify the use of SQLAlchemy in Flask, providing useful defaults and additional helpers to make common tasks easier.

1) to install sqlalchemy, open the command line of windows: pip install sqlalchemy


E:\workdir\blog2>pip install sqlalchemy

2), then install flask-sqlalchemy


E:\workdir\blog2>pip install flask-sqlalchemy

3) verify whether the installation of flask-sqlalchemy is successful


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, the installation was successful.

At this point, the development environment of flask has been completed, and the next article will be put into practice.

References:

【 flask quickstart Chinese 】 http: / / docs jinkan. org/docs flask /

【 flask quickstart English 】 http: / / flask pocoo. org/docs / 0.11 /

flask - sqlalchemy Chinese http 】 : / / www pythondoc. com/flask - sqlalchemy/index html

flask - sqlalchemy Chinese http 】 : / / flask - sqlalchemy pocoo. org / 2.1 /


Related articles: