【发布时间】:2017-03-20 17:53:58
【问题描述】:
我在一个页面方向上有 2 个功能。
如何分别访问它们?
现在发生的事情是,只有第一个函数被调用。
下面的程序是一个虚构的原型,我的要求建立在这个逻辑之上。
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)
【问题讨论】: