@csrf_exempt
def most_popular_word_get(request):
    print('most_popular_word_get')
    place_list = []
    word_list = []
    counter_list = []
    if (request.method == 'POST'):
        queriesManager = QueriesManager()
        (name, locations, start_date, end_date, word_list, logic, exact) = parse_parameters(request)
        days_list = generate_days_list(start_date, end_date)
        total_tweets = get_tweet_list(locations, get_user(name), days_list, None, asdocs=True)
        if isinstance(total_tweets, Exception):
            return JsonResponse(str(total_tweets), safe=False, status=500)
        elif (len(total_tweets) == 0):
            return JsonResponse('Error: No Tweets in location and date', safe=False, status=500)
        params = ['Popular_word_per_place']
        df = queriesManager.call_querie(params, total_tweets, [])
        print(df)
        for (i, row) in df.iterrows():
            place_list.append(row['place_name'])
            word_list.append(row['popular_word'])
            counter_list.append(row['counter'])
    return JsonResponse({'places': place_list, 'words': word_list, 'counters': counter_list}, safe=False)
@csrf_exempt
def most_popular_word_get(request):
    print('most_popular_word_get')
    place_list = []
    word_list = []
    counter_list = []
    if (request.method == 'POST'):
        queriesManager = QueriesManager()
        (name, locations, start_date, end_date, word_list, logic, exact) = parse_parameters(request)
        days_list = generate_days_list(start_date, end_date)
        total_tweets = get_tweet_list(locations, get_user(name), days_list, None, asdocs=True)
        if isinstance(total_tweets, Exception):
            return JsonResponse(str(total_tweets), safe=False, status=500)
        elif (len(total_tweets) == 0):
            return JsonResponse('Error: No Tweets in location and date', safe=False, status=500)
        params = ['Popular_word_per_place']
        df = queriesManager.call_querie(params, total_tweets, [])
        print(df)
        for (i, row) in df.iterrows():
            place_list.append(row['place_name'])
            word_list.append(row['popular_word'])
            counter_list.append(row['counter'])
    return JsonResponse({'places': place_list, 'words': word_list, 'counters': counter_list}, safe=False)