Ejemplo n.º 1
0
# Parse only known arguments because others arguments are added during
# a DB migration.
args, unknown = parser.parse_known_args()
config_file = args.config_file

# The default YAML config file is the option is not provided.
if config_file is None:
    config_file = os.environ.get('CAPSULE_API_CONFIG')

if config_file is None:
    if Path('config.yml').is_file():
        config_file = 'config.yml'
    else:
        config_file = '/etc/capsule-api/config.yml'

yamlconfig = YamlConfig(config_file)

connex_app = create_app(yamlconfig)
app = connex_app.app

from app import oidc


@app.after_request
def log_request_info(response):
    """ build log :
        ip - user "METHOD path" response_code "server" "user_agent" [payload=]
    """
    request_ip = request.remote_addr
    request_method = request.method
    request_server = request.url_root