def test_creates_app_with_defaults_and_starts_thread(self): self.app_mock.listen(8001, "0.0.0.0", io_loop=mox.IsA(ioloop.IOLoop)) self.thread_mock.daemon = True self.thread_mock.start() self.mox.ReplayAll() server.start() self.mox.VerifyAll()
def test_creates_app_and_starts_thread(self): custom_port = 8123 custom_addr = "192.168.1.1" self.app_mock.listen(custom_port, custom_addr, io_loop=mox.IsA(ioloop.IOLoop)) self.thread_mock.daemon = True self.thread_mock.start() self.mox.ReplayAll() server.start(custom_addr, custom_port) self.mox.VerifyAll()
from overlord import server, wrapper app = Flask(__name__) @wrapper.call_stats def time_consuming_function(amount): time.sleep(amount) # XXX: adding decorator on top will not cause stats to update, bacause Flask # internally stores reference to decorated function # @wrapper.call_stats @app.route("/") @app.route("/user/<username>") @wrapper.call_stats def hello(username="******"): app.logger.debug("Debug message!") app.logger.info("Info message!") time_consuming_function(random.random() * 3) time_consuming_function(random.random()) return "Hello %(username)s!" % locals() if __name__ == "__main__": server.start() app.run()