python - 重定向到 Pyramid 中的其他网址?

标签 python post redirect pyramid pylons

我正在铺设双向 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/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 响应的一个子类.

关于python - 重定向到 Pyramid 中的其他网址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16783821/

相关文章:

php - Wordpress 组合查询

api - Grails 如何发布到别人的 API

Python Bottle - "redirect"和 "return template"之间的区别

apache - 重定向除 htaccess 中的少数路径之外的所有路径

python - matplotlib PdfPages - 存储具有大量数据的绘图的有损副本

python - 用零替换数据框中的上三角和下三角值,或仅保留对角线值

php - 同一行不同列中的复选框值php

python - Django 重定向传递一个(或多个)对象作为参数

python - sklearn kfold 在 python 中返回错误的索引

python - kivy 应用程序中的一个简单网页作为小部件