首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在烧瓶中从单一路径调用多个函数

在烧瓶中从单一路径调用多个函数
EN

Stack Overflow用户
提问于 2017-02-27 11:12:24
回答 1查看 5.7K关注 0票数 0

我在一个页面的一个方向上有两个函数。

如何单独访问他们两个人? 现在发生的是,只有第一个函数被调用。

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

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-18 00:53:32

你问这个问题的方式意味着你想从同一个地址提供两个独立的网页。休息不是这样的。

您需要提供第二条路径来访问page2()中的代码

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42484322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档