table of Contents
1. Introduction to Flask
Flask , a lightweight web application framework written in Python, relies on the Jinja template engine and the Werkzeug WSGI suite
Flask, also known as the microframework. The goal is to keep the core of the application simple and extensible
Jinja2 is a popular template engine for Python. Used to present dynamic web pages
WSGI, Web Server Gateway Interface, Web server gateway interface, is the interface specification between Web server and Web application
Werkzeug, a WSGI toolkit, which implements request, response objects and utility functions. So that you can build a web framework on top of it
2. Flask deployment
3. Based on the flask framework to develop the Web world Hello World example
from flask import Flask # 导入flask框架的包
app = Flask(__name__) # 创建一个flask的APP,就是应用本身
@app.route('/') # 给APP指定路由,即当前访问的URL,默认是根目录的时候,执行下面的函数,此处起到了API的作用
def hello_world():
return '你好,世界!'
if __name__ == "__main__": # 这里的作用是用来做部署的,执行这个内容
app.run(host='127.0.0.1', port=8080) # 会在本地创建IP:127.0.0.1,端口是8080