我有一条烧瓶路线:
@app.route('/')
def index():
return render_template('index.html')
我可以在其他地方定义函数并装饰函数调用吗?
from module import index
@app.route('/')
index()
我对装饰器没有基本的了解,我也不确定标准行为是否与Flask有关,因此在此先感谢您的澄清。
在这种情况下,您不能修饰函数调用,但是可以定义需要调用的新函数:
from module import index
@app.route('/')
def new_index()
return index()
甚至很简单,就像@JoranBeasley提出的那样:
app.route("/")(index)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句