0

I have a small python/flask application on Microsoft Azure, here: https://sdtflask.azurewebsites.net/#!/

This is being developed on my local machine and then pushed to GitHub where it automatically gets deployed to Azure. Everything works fine on both ends except for a tiny part of the app, which is a http request to the youtube API to retrieve some information from a youtube channel.

This works fine on my local machine, however when tried on Azure, it doesn't.

The code is the same on both ends:

import requests
from flask_restful import Resource

class GetChannelList(Resource):
    def get(self):
        try:
            url = "https://content.googleapis.com/youtube/v3/search?key=AIzaSyCxd3KGNNiZy-omyDH7U8Lr3zGQD6ZO448&channelId=UCvS6-K6Ydmb4gH-kim3AmjA&part=snippet,id&order=date&maxResults=50"
            r = requests.get(url).json()
            # r.raise_for_status()
            return r
        except Exception as e:
            print(str(e))
            return {'message': 'something went wrong'}

Then I have the following:

from flask import Flask
from flask_restful import Api
from api.get_channel_list import GetChannelList
app = Flask(__name__)

api = Api(app)

api.add_resource(GetChannelList, "/api/get_channel_list")

import FlaskWebProject1.views

And then on my Angular controller I do the following:

angular.module('sdt')
    .controller('mainCtrl', function($scope, $http){
        $scope.showResults = function(){
            $scope.data = $http.get('api/get_channel_list').then(function(data){
                console.log(data);
                $scope.printTable(data);
            });
          }
            $scope.printTable = function(data){
                $scope.pageToken = data.data.nextPageToken;
                // $scope.fetchMore($scope.pageToken);
                $scope.items = data.data.items;
            }
    });

it works fine on my local machine:

enter image description here enter image description here

But once I deploy to server, it doesn't load anything and this is what I get on the console's JSON:

enter image description here

I checked the application streaming logs and no errors are shown, there's also no python error, which makes me believe maybe azure blocks the request? Anyone has any idea what might be going on? Any pointers as to what I may do next will be appreciated. Thanks in advance

CodeTrooper
  • 1,890
  • 6
  • 32
  • 54

1 Answers1

1

Maybe Python Requests throwing up SSLError will help you to figure out why there is a SSLException happening

looks like the the quickest fix is setting verify=False. (taken from the answer in the link)

PYA
  • 8,096
  • 3
  • 21
  • 38