<commit_before>""" Heroku/Python Quickstart: https://blog.heroku.com/archives/2011/9/28/python_and_django"""

import os
import random
import requests
from flask import Flask

import tweepy

import settings


app = Flask(__name__)


@app.route('/')
def home_page():
    return 'Hello from the SPARK learn-a-thon!'


def get_instagram_images():
    instagram_api_url = 'https://api.instagram.com/v1/tags/spark/media/recent?client_id={}'.format(settings.CLIENT_ID)

    data = requests.get(instagram_api_url).json()['data']
    number_of_images = choose_number_of_images()

    images_returned = []
    for image in range(0, number_of_images):
        choice = random.choice(data)
        img_url = choice['link']
        image = choice['images']['low_resolution']['url']
        images_returned.append((img_url, image))

    return images_returned


def get_tweets():
    auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
    auth.set_access_token(settings.ACCESS_KEY, settings.ACCESS_SECRET)
    api = tweepy.API(auth)

    number_of_tweets = choose_number_of_tweets()

    tweets = tweepy.Cursor(api.search, q='#spark')

    tweets_html = [api.get_oembed(tweet.id)['html'] for tweet in list(tweets.items(limit=number_of_tweets))]

    return tweets_html


def choose_number_of_images():
    number = 3
    return number


def choose_number_of_tweets():
    number = 3
    return number


if __name__ == '__main__':
    # port = int(os.environ.get("PORT", 5000))
    # app.run(host='0.0.0.0', port=port)
    get_instagram_images()
<commit_msg>add another function and take away port mess<commit_after>""" Heroku/Python Quickstart: https://blog.heroku.com/archives/2011/9/28/python_and_django"""

import os
import random
import requests
from flask import Flask

import tweepy

import settings


app = Flask(__name__)


@app.route('/')
def home_page():
    return 'Hello from the SPARK learn-a-thon!'


def get_instagram_images():
    instagram_api_url = 'https://api.instagram.com/v1/tags/spark/media/recent?client_id={}'.format(settings.CLIENT_ID)

    data = requests.get(instagram_api_url).json()['data']
    number_of_images = choose_number_of_images()

    images_returned = []
    for image in range(0, number_of_images):
        choice = choose_a_random_item(data)
        img_url = choice['link']
        image = choice['images']['low_resolution']['url']
        images_returned.append((img_url, image))

    return images_returned


def choose_a_random_item(list):
    """ Given a list of items, return a random element of that list
    """
    return random.choice(list)


def get_tweets():
    auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
    auth.set_access_token(settings.ACCESS_KEY, settings.ACCESS_SECRET)
    api = tweepy.API(auth)

    number_of_tweets = choose_number_of_tweets()

    tweets = tweepy.Cursor(api.search, q='#spark')

    tweets_html = [api.get_oembed(tweet.id)['html'] for tweet in list(tweets.items(limit=number_of_tweets))]

    return tweets_html


def choose_number_of_images():
    number = 3
    return number


def choose_number_of_tweets():
    number = 3
    return number


if __name__ == '__main__':
    port = int(os.environ.get("PORT", 5000))
    app.run(host='0.0.0.0', port=port)

{'fraction_non_alphanumeric': 0.12423873325213154, 'fraction_numerical': 0.011571254567600487, 'mean_word_length': 4.140845070422535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1573054', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1131, 'n_words': 214}