Exemplo n.º 1
0
def getweather(request, location):
    """
        Returns the weather for the requested location
    """
    weather = get_weather_by_location(location)
    resp = twilio.twiml.Response()   
    resp.sms(weather)
    print "Twilio's response for " + location + "'s weather : " + str(resp)      
    return HttpResponse(str(resp))
Exemplo n.º 2
0
def postweather(request):
    """
        Intercepts a POST request from twilio server, fetches the message parameters and
        then returns the weather for the specified city in TwiML format.
    """
    params = request.POST
    print "POST request parameters : " + str(params)

    location = params['Body'].strip()
    
    weather = get_weather_by_location(location)
    resp = twilio.twiml.Response()   
    resp.sms(weather)
    print "Twilio's response for " + location + "'s weather : " + str(resp)      
    return HttpResponse(str(resp))