Use a create_app function

r? (@mythmon)