from __future__ import absolute_import, print_function

from flask import Flask


def create_app(name='butts', debug=False):
    app = Flask(name)
    app.debug = debug
    app.add_url_rule('/', 'index', lambda: "INDEX")
    app.add_url_rule('/yow', 'yow', lambda: "YOW")
    return app

@@ -53,31 +53,120 @@
 on%0A%0A
-from flask import Flask
+import multiprocessing%0Aimport time%0A%0Afrom flask import Flask%0A%0A__all__ = ('create_app', 'BackgroundServerWrapper')
 %0A%0A%0Ad
@@ -369,8 +369,545 @@
 urn app%0A
+%0A%0Aclass BackgroundServerWrapper(object):%0A    %22%22%22Wraps a flask application and allows it to be run in the background.%22%22%22%0A%0A    def __init__(self, app, port=5000):%0A        self.app = app%0A        self.port = port%0A        self._process = multiprocessing.Process(%0A            target=lambda app, port: app.run(port=port),%0A            args=(self.app, self.port)%0A        )%0A%0A    def start_server(self):%0A        self._process.start()%0A        time.sleep(1)%0A%0A    def stop_server(self):%0A        if self._process:%0A            self._process.terminate()%0A

add background process wrapper class