views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:smslists 作者: alando46 项目源码 文件源码
def dispatch(self, request, *args, **kwargs):

        response = super(TwilioResponseMixin, self).dispatch(request, *args, **kwargs)

        # handle view returning httpresponse instead of string.
        # this will allow more customizability if some functions return
        # and others return httpresponse objects.

        if isinstance(response, HttpResponse):
            if isinstance(response, SimpleTemplateResponse):
                response.render()
            content = response.content

        elif isinstance(response, basestring):
            content = response

        else:
            print type(response)
            content = ''

        twilio_response = twilio.twiml.Response()
        twilio_response.message(msg=content, to=request.session['phone_num'], 
            sender=PLIVO_NUMBER)
        response = HttpResponse(content=str(twilio_response))

        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号