title: Deploying flask app to Heroku - error H10 (App crashed)
body: <p>I am trying to deploy a simple flask application to Heroku, it is working fine locally, but when deploying to Heroku I get this error:</p>
  
  <pre><code>2016-05-05T18:39:24.897207+00:00 heroku[router]: at=error code=H10 
  desc="App crashed" method=GET path="/favicon.ico" host=read-
  laterr.herokuapp.com request_id=2ab420c2-64df-4544-9aaf-675ae5f5abfa 
  fwd="87.56.186.149" dyno= connect= service= status=503 bytes=
  </code></pre>
  
  <p>I know it comes because my web dyno crashes, but I just don't know why it crashes. </p>
  
  <p>Here is my Procfile:</p>
  
  <pre><code>web: gunicorn app:app
  </code></pre>
  
  <p>If I just deploy a single hello app it works but not if I deploy the code below in app.py:</p>
  
  <p>And my app.py:</p>
  
  <pre><code>from __future__ import absolute_import, print_function
  from tweepy import StreamListener
  from tweepy import OAuthHandler
  from tweepy import Stream
  import os
  import json
  import time
  from flask import Flask, render_template
  
  app = Flask(__name__)
  
  
  @app.route("/")
  def index():
      return render_template("index.html", articles=sorted(articles, key=lambda article: article["liked_on"], reverse=True))
  
  
  consumer_key="xxxkeyxxx"
  consumer_secret="xxxsecretxxx"
  access_token="xxxtokenxxx"
  access_token_secret="xxxtokensecretxxx"
  
  articles = []
  
  class LikedTweetsListener(StreamListener):
      def on_data(self, data):
          tweet = json.loads(data)
          if 'event' in tweet and tweet['event'] == "favorite":
              liked_tweet = tweet["target_object"]
              liked_tweet_text = liked_tweet["text"]
              story_url = extract_url(liked_tweet)
              if story_url:
                  article = extract_article(story_url)
                  if article:
                      article['story_url'] = story_url
                      article['liked_on'] = time.time()
                      articles.append(article)
          return True
  
      def on_error(self, status):
          print("Error status received : {0}".format(status))
  
  
  def extract_url(liked_tweet):
      url_entities = liked_tweet["entities"]["urls"]
      if url_entities and len(url_entities) &gt; 0:
          return url_entities[0]['expanded_url']
      else:
          return None
  
  
  from newspaper import Article
  
  def extract_article(story_url):
      article = Article(story_url)
      article.download()
      article.parse()
      title = article.title
      img = article.top_image
      publish_date = article.publish_date
      text = article.text.split('\n\n')[0] if article.text else ""
      return {
          'title':title,
          'img':img,
          'publish_date':publish_date,
          'text':text.encode('ascii','ignore')
      }
  
  
  if __name__ == '__main__':
      l = LikedTweetsListener()
      auth = OAuthHandler(consumer_key, consumer_secret)
      auth.set_access_token(access_token, access_token_secret)
  
      stream = Stream(auth, l)
      stream.userstream(async=True)
  
      port = int(os.environ.get('PORT', 33507))
      app.run(host='0.0.0.0', port=port)
  </code></pre>
  
  <p>Any help would be much appreciated!</p>