[Xiaobai series] Looking at it, a simple introduction to the web application framework flask written in Python and the development of the Hello world example in the web world based on the flask framework

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

Insert picture description here
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

Insert picture description here

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

Insert picture description here

Published 42 original articles · praised 28 · visits 4961

Guess you like

Origin blog.csdn.net/KaelCui/article/details/105275464