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

import os
import random
import requests
import tweepy
from flask import Flask, render_template

import settings

app = Flask(__name__)


@app.route('/')
def home_page():
    instagram_pics = get_instagram_images()
    twitter_pics = get_tweets()

    return render_template(
        'home.html', name='main', 
        instagram_pics=instagram_pics, 
        twitter_pics=twitter_pics,
    )


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(port=port, debug=True)


@@ -487,34 +487,339 @@
  )%0A%0A
-%0Adef get_instagram_images(
+@app.route('/%3Chashtag%3E')%0Adef hashtag_pages(hashtag):%0A    instagram_pics = get_instagram_images(hashtag)%0A    twitter_pics = get_tweets(hashtag)%0A%0A    return render_template(%0A        'home.html', name='main', %0A        instagram_pics=instagram_pics, %0A        twitter_pics=twitter_pics,%0A    )%0A%0A%0A%0Adef get_instagram_images(hashtag='spark'
 ):%0A 
@@ -876,21 +876,18 @@
 v1/tags/
-spark
+%7B%7D
 /media/r
@@ -913,16 +913,25 @@
 .format(
+hashtag, 
 settings
@@ -1488,24 +1488,39 @@
  get_tweets(
+hashtag='spark'
 ):%0A    auth 
@@ -1782,22 +1782,35 @@
 ch, q='#
-spark'
+%7B%7D'.format(hashtag)
 )%0A%0A    t

add additional route