Flask路由

Flask教程 · 2019-04-25 17:37:46

现代Web框架使用路由技术来帮助用户记住应用程序URL。 无需从主页导航即可直接访问所需页面。

Flask中的route()装饰器用于将URL绑定到函数。 例如 -

@app.route('/hello')
def hello_world():
    return 'hello world'

这里,URL /hello规则绑定到hello_world()函数。 因此,如果用户访问URL : http://localhost:5000/hello ,就会调用hello_world()函数,这个函数中的执行的结果输出将在浏览器中呈现。

应用程序对象的add_url_rule()函数也可用于将URL与函数绑定,如上例所示,使用route()

def hello_world():
    return 'hello world'

app.add_url_rule('/', 'hello', hello_world)

点击查看所有 Flask教程 文章: https://www.codercto.com/courses/l/47.html

查看所有标签

High Performance Python

High Performance Python

Andrew Lewis / O'Reilly Media, Inc. / 2010-09-15 / USD 34.99

Chapter 1. Introduction Section 1.1. The High Performance Buzz-word Chapter 2. The Theory of Computation Section 2.1. Introduction Section 2.2. Problems Section 2.3. Models of Computati......一起来看看 《High Performance Python》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具