search
HomeBackend DevelopmentPython TutorialFlask framework study guide - development environment setup

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/


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Flask + Vue.js:快速实现单页面应用Flask + Vue.js:快速实现单页面应用Jun 17, 2023 am 09:06 AM

随着移动互联网和Web技术的迅速发展,越来越多的应用需要提供流畅、快速的用户体验。传统的多页面应用已经无法满足这些需求,而单页面应用(SPA)则成为了解决方案之一。那么,如何快速实现单页面应用呢?本文将介绍如何利用Flask和Vue.js来构建SPA。Flask是一个使用Python语言编写的轻量级Web应用框架,它的优点是灵活、易扩

如何使用python+Flask实现日志在web网页实时更新显示如何使用python+Flask实现日志在web网页实时更新显示May 17, 2023 am 11:07 AM

一、日志输出到文件使用模块:logging可以生成自定义等级日志,可以输出日志到指定路径日志等级:debug(调试日志)=5){clearTimeout(time)//如果连续10次获取的都是空日志清除定时任务}return}if(data.log_type==2){//如果获取到新日志for(i=0;i

Flask和Intellij IDEA集成: Python web应用程序开发技巧(第二部分)Flask和Intellij IDEA集成: Python web应用程序开发技巧(第二部分)Jun 17, 2023 pm 01:58 PM

在第一部分介绍了基本的Flask和IntellijIDEA集成、项目和虚拟环境的设置、依赖安装等方面的内容。接下来我们将继续探讨更多的Pythonweb应用程序开发技巧,构建更高效的工作环境:使用FlaskBlueprintsFlaskBlueprints允许您组织应用程序代码以便于管理和维护。Blueprint是一个Python模块,能够包

Flask-RESTful和Swagger: Python web应用程序中构建RESTful API的最佳实践(第二部分)Flask-RESTful和Swagger: Python web应用程序中构建RESTful API的最佳实践(第二部分)Jun 17, 2023 am 10:39 AM

Flask-RESTful和Swagger:Pythonweb应用程序中构建RESTfulAPI的最佳实践(第二部分)在上一篇文章中,我们探讨了如何使用Flask-RESTful和Swagger来构建RESTfulAPI的最佳实践。我们介绍了Flask-RESTful框架的基础知识,并展示了如何使用Swagger来构建RESTfulAPI的文档。本

Flask和Sublime Text集成: Python web应用程序开发技巧(第六部分)Flask和Sublime Text集成: Python web应用程序开发技巧(第六部分)Jun 17, 2023 pm 04:08 PM

Flask和SublimeText集成:Pythonweb应用程序开发技巧(第六部分)SublimeText和Flask都是Pythonweb应用程序开发中的重要工具。然而,如何将二者集成起来,使得开发过程更加高效呢?本文将介绍一些SublimeText的插件和配置技巧,帮助你更方便地开发Flask应用程序。一、安装SublimeText插件F

Flask和Eclipse集成: Python web应用程序开发技巧(第三部分)Flask和Eclipse集成: Python web应用程序开发技巧(第三部分)Jun 17, 2023 pm 03:27 PM

Flask和Eclipse集成:Pythonweb应用程序开发技巧(第三部分)在前两篇文章中,我们介绍了如何将Flask与Eclipse集成,以及如何创建Flask应用程序。在本文中,我们将继续探讨如何开发和调试Flask应用程序,以及如何管理数据库。一、开发和调试Flask应用程序创建和运行Flask应用程序在Eclipse的ProjectExplo

Flask-Security: 在Python web应用程序中添加用户身份验证和密码加密Flask-Security: 在Python web应用程序中添加用户身份验证和密码加密Jun 17, 2023 pm 02:28 PM

Flask-Security:在Pythonweb应用程序中添加用户身份验证和密码加密随着互联网的不断发展,越来越多的应用程序需要用户身份验证和密码加密来保护用户数据的安全性。而在Python语言中,有一个非常流行的Web框架——Flask。Flask-Security是基于Flask框架的一个扩展库,它可以帮助开发人员在Pythonweb应用程序中轻

Python Flask JinJa2语法如何使用Python Flask JinJa2语法如何使用May 16, 2023 am 09:19 AM

一、概述Flask是一个轻量级的PythonWeb框架,支持Jinja2模板引擎。Jinja2是一个流行的Python模板引擎,它可以使用Flask来创建动态Web应用程序。web页面一般需要html、css和js,可能最开始学习pythonweb的时候可能这样写:fromflaskimportFlaskapp=Flask(__name__)@app.route('/')defhello():return'hellohelloworld!!!&am

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),