Flask框架 之模块划分

缺点:不好确定函数对应的url地址

一、示例代码

run.py

from flask import Flask
from controllers.index import index
from controllers.register import register
from controllers.login import login

app = Flask(__name__)

app.route("/")(index)
app.route("/register")(register)
app.route("/login")(login)

if __name__ == "__main__":

    app.run(debug=True)

controllers

login.py

def login():
    return "login page"

 

posted @ 2023-03-31 10:32  样子2018  阅读(31)  评论(0编辑  收藏  举报