# -*- coding: utf-8 -*-
from url_shortener import app, custom_config_loaded, views

log_file = app.config['LOG_FILE']

if not app.debug and log_file is not None:
    import logging
    from logging.handlers import TimedRotatingFileHandler
    file_handler = TimedRotatingFileHandler(log_file, when='d')
    file_handler.setLevel(logging.WARNING)
    app.logger.addHandler(file_handler)

app.config.from_envvar('URL_SHORTENER_CONFIGURATION')
custom_config_loaded.send(app)

app.run()

# -*- coding: utf-8 -*-
from url_shortener import app, views
from url_shortener.validation import configure_url_validator
from url_shortener.models import configure_random_factory

log_file = app.config['LOG_FILE']

if not app.debug and log_file is not None:
    import logging
    from logging.handlers import TimedRotatingFileHandler
    file_handler = TimedRotatingFileHandler(log_file, when='d')
    file_handler.setLevel(logging.WARNING)
    app.logger.addHandler(file_handler)

app.config.from_envvar('URL_SHORTENER_CONFIGURATION')
configure_url_validator(app)
configure_random_factory(app)


app.run()

Refactor applying custom configuration after it is loaded
Refactor applying custom configuration after it is loaded

The call sending custom_config_loaded is being replaced with direct
calls to the functions configure_random_factory and configure_url_validator.
