Update app.py to work with EBS WSGI

The ElasticBeanstalk application looks for an object named `application` to run with `WSGI` this was previously created with the `create_app` method and used `app` as the name for the application object.
add-new-regnum-params
Mike Benowitz 2019-07-05 14:59:08 -04:00
parent 02b6462b9e
commit 0542d85b89
1 changed files with 21 additions and 27 deletions

View File

@ -15,31 +15,25 @@ def loadConfig():
for key, value in sectionDict.items():
os.environ[key] = value
def create_app():
loadConfig()
app = Flask(__name__)
app.register_blueprint(base.bp)
app.register_blueprint(search.search)
app.register_blueprint(uuid.uuid)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://{}:{}@{}:{}/{}'.format(
os.environ['DB_USER'],
os.environ['DB_PSWD'],
os.environ['DB_HOST'],
os.environ['DB_PORT'],
os.environ['DB_NAME']
)
app.config['ELASTICSEARCH_INDEX_URI'] = '{}:{}'.format(
os.environ['ES_HOST'],
os.environ['ES_PORT']
)
app.config['SWAGGER'] = {'title': 'CCE Search'}
db.init_app(app)
elastic.init_app(app)
docs = SwaggerDoc()
swagger = Swagger(app, template=docs.getDocs())
return app
loadConfig()
if __name__ == '__main__':
create_app()
application = Flask(__name__)
application.register_blueprint(base.bp)
application.register_blueprint(search.search)
application.register_blueprint(uuid.uuid)
application.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://{}:{}@{}:{}/{}'.format(
os.environ['DB_USER'],
os.environ['DB_PSWD'],
os.environ['DB_HOST'],
os.environ['DB_PORT'],
os.environ['DB_NAME']
)
application.config['ELASTICSEARCH_INDEX_URI'] = '{}:{}'.format(
os.environ['ES_HOST'],
os.environ['ES_PORT']
)
application.config['SWAGGER'] = {'title': 'CCE Search'}
db.init_app(application)
elastic.init_app(application)
docs = SwaggerDoc()
swagger = Swagger(application, template=docs.getDocs())