从 Flask 中的单个路由调用多个函数

Call multiple functions from a single route in flask

我在页面的一个方向上有2个功能。

How to access both of them individually?
Now what's happening is, only 1st function is getting called.

下面的程序是虚构的原型,我的要求建立在这个逻辑上。

from bottle import get,post,run,route,request

content1 = ''' 
<html>
<h1>Page 1 function </h1>
<form action='details' method='post'>
<input type = "text" name="uname">
<input type = "submit" >
</form>
</html>'''

content11 = ''' 
<html>
<h1>Page 2 function </h1>
<form action='details' method='post'>
<input type = "text" name="uname">
<input type = "submit" >
</form>
</html>'''

content2 = '''<html><h1>Hello %s </h1></html>'''

@get('/home')
def page1():
    return content1

def page2():
    return content11  

@post('/details')
def page3():
    u_name = str(request.forms.get('uname'))
    return content2 %u_name

run(host='localhost', port=8080, debug=True)

你问问题的方式暗示你想从同一个地址提供两个单独的网页。 REST 不能这样工作。

您需要提供第二条途径来访问 page2()

中的代码