我正在铺设双向 SMS 服务。
用户将向短信服务器平台(www.sms.com)提供的虚拟号码发送短信。该短信服务器平台会将用户短信数据传递到我的网址(http://www.yourdomainname.com/ReceiveSMS?from=from&message=message)
现在我根据“消息”处理用户请求,然后我需要回复这个网址 (www.sms.com/optin.php?user=username&pass=password&to=to_mobile_number&message=dynamic_message)
我的问题是如何在处理后将其发布到 url www.sms.com/optin.php?user=username&pass=password&to=to_mobile_number&message=dynamic_message。
我想到的一种方法是使用 HTTPFound。
想知道是否有更有效的方法?
最佳答案
在 Pyramid View 中,您可以返回 webob响应侧步任何渲染器逻辑。因此,对于重定向,您将状态设置为 301/302和 location 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 响应的一个子类.
关于python - 重定向到 Pyramid 中的其他网址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16783821/