Factory function that creates a new `CoolmagicApplication`
    object. Optional WSGI middlewares should be applied here.

def make_app(config=None):
    """
    Factory function that creates a new `CoolmagicApplication`
    object. Optional WSGI middlewares should be applied here.
    """
    config = config or {}
    app = CoolMagicApplication(config)

    # static stuff
    app = SharedDataMiddleware(
        app, {"/public": path.join(path.dirname(__file__), "public")}
    )

    # clean up locals
    app = local_manager.make_middleware(app)

    return app