I have a website with a form in which a user enters an IP address. When the 
form is "submitted" (actually, an AJAX call is made, which updates the 
form), the part of the form that's updated via the AJAX call shows a "502 
Bad Gateway nginx 1.8" error - this happens when attempting to get youtube 
data from Google's Youtube API, V3. The code that gets data from the google 
API is as follows:

def get_youtube_data_via_API(self, video_id, production = False):
    try:
        if production or self.settings.url in self.request.env.HTTP_HOST:   
            api_key = ... # production API Key
        else:         
            api_key= ... # testing API key
        # generate the API URL
        api_url = "https://www.googleapis.com/youtube/v3/videos?id="; + \
            str(video_id) + "&key=" + api_key + "&part=snippet"
        # get the data
        response = requests_get(api_url)
        return json_loads(response.text)
    except Exception as e:
        # print exception and write it to file

I'd appreciate any suggestions as to what could be going wrong here, or on 
how to diagnose or resolve it. Thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to