其他分享
首页 > 其他分享> > 重定向到金字塔中的其他URL?

重定向到金字塔中的其他URL?

作者:互联网

我正在铺设2向SMS服务.

用户将向SMS服务器平台(www.sms.com)提供的虚拟号码发送SMS.该SMS服务器平台会将用户SMS数据传递到我的网址(http://www.yourdomainname.com/ReceiveSMS?from=from&message=message)

现在,我根据“消息”处理用户请求,然后我需要发布对此URL的回复
(www.sms.com/optin.php?user=用户名& pass =密码& to = to_mobile_number& message = dynamic_message)

我的问题是处理后如何将其发布到网址www.sms.com/optin.php?user=username\u0026amp;pass=password\u0026amp;to=to_mobile_number\u0026message=dynamic_message.

我想到的一种方式是使用HTTPFound.

想知道是否有更有效的方法?

解决方法:

在金字塔视图中,您可以向任何渲染器逻辑返回webob响应以进行下一步.因此,对于重定向,您将状态设置为301/302location header.

from webob import Response

@view_config(...)
def your_view(context, request):
    # do stuff
    return Response(status_int=302, location="http://goherenext.com")

HTTPFound只是status hard-coded响应的子类.

标签:pylons,post,redirect,pyramid,python
来源: https://codeday.me/bug/20191123/2066116.html