forked from uwcirg/helloworld-confidential-client-sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
# from flask import Flask | ||
# import logging | ||
# from logging import config as logging_config | ||
# import os | ||
# from werkzeug.middleware.proxy_fix import ProxyFix | ||
from flask import Flask | ||
import logging | ||
from logging import config as logging_config | ||
import os | ||
from werkzeug.middleware.proxy_fix import ProxyFix | ||
|
||
# from fhir_migrations import commands as migration_commands | ||
# from isacc_messaging.api import views | ||
# from isacc_messaging.audit import audit_entry, audit_log_init | ||
# from isacc_messaging.extensions import oauth | ||
from isacc_messaging.api import views | ||
from isacc_messaging.audit import audit_entry, audit_log_init | ||
from isacc_messaging.extensions import oauth | ||
|
||
# def create_app(testing=False, cli=False): | ||
# """Application factory, used to create application | ||
# """ | ||
# app = Flask('isacc_messaging') | ||
# app.config.from_object('isacc_messaging.config') | ||
# app.config['TESTING'] = testing | ||
def create_app(testing=False, cli=False): | ||
"""Application factory, used to create application | ||
""" | ||
app = Flask('isacc_messaging') | ||
app.config.from_object('isacc_messaging.config') | ||
app.config['TESTING'] = testing | ||
|
||
# configure_logging(app) | ||
# configure_extensions(app, cli) | ||
# register_blueprints(app) | ||
# configure_proxy(app) | ||
configure_logging(app) | ||
configure_extensions(app, cli) | ||
register_blueprints(app) | ||
configure_proxy(app) | ||
|
||
# return app | ||
return app | ||
|
||
|
||
# def configure_logging(app): | ||
# app.logger # must call to initialize prior to config or it'll replace | ||
def configure_logging(app): | ||
app.logger # must call to initialize prior to config or it'll replace | ||
|
||
# config = 'logging.ini' | ||
# if not os.path.exists(config): | ||
# # look above the testing dir when testing or debugging locally | ||
# config = os.path.join('..', config) | ||
config = 'logging.ini' | ||
if not os.path.exists(config): | ||
# look above the testing dir when testing or debugging locally | ||
config = os.path.join('..', config) | ||
|
||
# logging_config.fileConfig(config, disable_existing_loggers=False) | ||
# app.logger.setLevel(getattr(logging, app.config['LOG_LEVEL'].upper())) | ||
logging_config.fileConfig(config, disable_existing_loggers=False) | ||
app.logger.setLevel(getattr(logging, app.config['LOG_LEVEL'].upper())) | ||
|
||
# if not app.config['LOGSERVER_URL'] or not app.config['LOGSERVER_TOKEN']: | ||
# app.logger.debug( | ||
# "isacc messaging service logging initialized", | ||
# extra={'tags': ['testing', 'logging', 'app']}) | ||
# return | ||
if not app.config['LOGSERVER_URL'] or not app.config['LOGSERVER_TOKEN']: | ||
app.logger.debug( | ||
"isacc messaging service logging initialized", | ||
extra={'tags': ['testing', 'logging', 'app']}) | ||
return | ||
|
||
# audit_log_init(app) | ||
# audit_entry( | ||
# "isacc messaging service logging initialized", | ||
# extra={'tags': ['testing', 'logging', 'events'], | ||
# 'version': app.config['VERSION_STRING']}) | ||
audit_log_init(app) | ||
audit_entry( | ||
"isacc messaging service logging initialized", | ||
extra={'tags': ['testing', 'logging', 'events'], | ||
'version': app.config['VERSION_STRING']}) | ||
|
||
|
||
# def configure_extensions(app, cli): | ||
# """configure flask extensions | ||
# """ | ||
# oauth.init_app(app) | ||
def configure_extensions(app, cli): | ||
"""configure flask extensions | ||
""" | ||
oauth.init_app(app) | ||
|
||
|
||
# def register_blueprints(app): | ||
# """register all blueprints for application | ||
# """ | ||
# app.register_blueprint(views.base_blueprint) | ||
# app.register_blueprint(migration_commands.migration_blueprint) | ||
def register_blueprints(app): | ||
"""register all blueprints for application | ||
""" | ||
app.register_blueprint(views.base_blueprint) | ||
# app.register_blueprint(migration_commands.migration_blueprint) | ||
|
||
|
||
# def configure_proxy(app): | ||
# """Add werkzeug fixer to detect headers applied by upstream reverse proxy""" | ||
# if app.config.get('PREFERRED_URL_SCHEME', '').lower() == 'https': | ||
# app.wsgi_app = ProxyFix( | ||
# app=app.wsgi_app, | ||
def configure_proxy(app): | ||
"""Add werkzeug fixer to detect headers applied by upstream reverse proxy""" | ||
if app.config.get('PREFERRED_URL_SCHEME', '').lower() == 'https': | ||
app.wsgi_app = ProxyFix( | ||
app=app.wsgi_app, | ||
|
||
# # trust X-Forwarded-Host | ||
# x_host=1, | ||
# trust X-Forwarded-Host | ||
x_host=1, | ||
|
||
# # trust X-Forwarded-Port | ||
# x_port=1, | ||
# ) | ||
# trust X-Forwarded-Port | ||
x_port=1, | ||
) |