title: Why does localhost:5000 not work in Flask?
body: <p>I'm using flask app factory pattern like and have this run.py file:</p>
  
  <pre><code>from app import create_app
  
  app = create_app()
  
  if __name__ == '__main__':
      app.run(host='localhost', debug=True)
  </code></pre>
  
  <p>Then I run the app like this:</p>
  
  <pre><code>python run.py
  </code></pre>
  
  <p>But when I go to <a href="http://localhost:5000" rel="noreferrer">http://localhost:5000</a> it doesn't work.
  It says:</p>
  
  <blockquote>
    <p>Not Found</p>
    
    <p>The requested URL was not found on the server. If you entered the URL
    manually please check your spelling and try again.</p>
  </blockquote>
  
  <p>What could be wrong? it works well when I have 127.0.0.1 address...</p>
  
  <p>I need to run on "localhost" because I'm integrating square payments and their sandbox setup requires I make requests to their API from a 'localhost'.</p>
  
  <p>Also, when I make the request in the browser, on the terminal when flask responds there is this:</p>
  
  <pre><code>127.0.0.1 - - [09/Sep/2017 00:30:45] "GET / HTTP/1.1" 404 -
  127.0.0.1 - - [09/Sep/2017 00:30:45] "GET /favicon.ico HTTP/1.1" 404 -
  127.0.0.1 - - [09/Sep/2017 00:30:45] "GET /favicon.ico HTTP/1.1" 404 -
  </code></pre>
  
  <p>So it looks like request reaches flask but flask returns 404.</p>
  
  <p>Here is part of my <strong>init</strong>.py file:</p>
  
  <pre><code># from __future__ import print_function
  
  
  # import flask
  from flask import Flask, render_template, url_for, redirect, flash, request, \
      session, current_app, abort
  import os
  # flask sqlaclhemy
  from sqlalchemy import func, desc, asc, or_, and_
  
  from flask_admin import Admin, AdminIndexView
  from flask_admin.contrib.sqla import ModelView
  
  # Flask secrutiy
  from flask_security import (Security, SQLAlchemyUserDatastore, 
      login_required, current_user)
  from flask_login import LoginManager
  from flask_mail import Mail
  
  # square connect setup
  import uuid
  import squareconnect
  from squareconnect.rest import ApiException
  # from squareconnect.apis.locations_api import LocationsApi
  from squareconnect.apis.transactions_api import TransactionsApi
  
  
  
  
  mail = Mail()
  
  class CustomAdminIndexView(AdminIndexView):
      def is_accessible(self):
          return current_user.is_authenticated and current_user.has_role('admin')
  
  def create_app():
      app = Flask(__name__)
      app.config.from_object(os.environ['APP_SETTINGS'])
      mail.init_app(app)
      from models import db, User, Role
      db.init_app(app)
  
      user_datastore = SQLAlchemyUserDatastore(db, User, Role)
      security = Security(app, user_datastore)
  
      @app.route('/')
      def home():
          return render_template('home.html')
  
      return app
  </code></pre>