Skip to content

Commit

Permalink
WIP: app
Browse files Browse the repository at this point in the history
  • Loading branch information
Filienko committed Jul 28, 2024
1 parent de3d0b0 commit 32b7b1b
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions isacc_messaging/app.py
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,
)

0 comments on commit 32b7b1b

Please sign in to comment.