from flask import Flask # 初始化 app = Flask(__name__) # 路由视图 @app.route('/') def index(): return '<h1>hello world </h1>' @app.route('/user/<name>') def user(name): return '<h1>hello {0}</h1>'.format(name) # 启动服务器 if __name__ == '__main__': app.run(debug=True)