def app(environ, response): # initialize API sand_app = Sand('./templates', './static') # add routes setup_routes(sand_app) # add exception handler sand_app.add_exception_handler(custom_exception_handler) # add middleware sand_app.add_middleware(LogMiddleware) # return WSGI compatible app return sand_app(environ, response)