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