python语言flask简单使用

一个简单服务器程序。访问根路径的时候,调用hello函数。

代码如下:

from flask import Flask


class app1:
    def __init__(self, name):
        self.app = Flask(name)

        # 根路径, 调用hello函数
        @self.app.route("/")
        def hello():
            return "hello world"


win1 = app1("hello")

if __name__ == '__main__':
    win1.app.run()


读书和健身总有一个在路上

原文地址:https://www.cnblogs.com/Renqy/p/12928397.html