def create(index="index.html", ngmodules=None, minify=True, locator=current): """ Creates wutu app :param index: html file for index page :param minify: Do we want to minify generated JavaScripts (should be False for debug purposes) :param locator: function which tells where to find templates :return: """ app = CustomFlask(__name__) api = Api(app) app.jinja_loader = jinja2.FileSystemLoader(locator()) api.jsstream = create_stream() create_base(api.jsstream, ngmodules) @app.route("/") def index_page(): """ Endpoint for base page :return: """ try: return render_template(index) except IOError: return "Failed to render template {0}, error: Not found".format( index) @lru_cache() @app.route("/wutu.js") def wutu_js(): if minify: from jsmin import jsmin jsdata = jsmin(get_data(api.jsstream)) else: from jsbeautifier import beautify jsdata = beautify(get_data(api.jsstream)) return Response(jsdata, mimetype="text/javascript") app.api = api return app
def create(index="index.html", ngmodules=None, minify=True, locator=current): """ Creates wutu app :param index: html file for index page :param minify: Do we want to minify generated JavaScripts (should be False for debug purposes) :param locator: function which tells where to find templates :return: """ app = CustomFlask(__name__) api = Api(app) app.jinja_loader = jinja2.FileSystemLoader(locator()) api.jsstream = create_stream() create_base(api.jsstream, ngmodules) @app.route("/") def index_page(): """ Endpoint for base page :return: """ try: return render_template(index) except IOError: return "Failed to render template {0}, error: Not found".format(index) @lru_cache() @app.route("/wutu.js") def wutu_js(): if minify: from jsmin import jsmin jsdata = jsmin(get_data(api.jsstream)) else: from jsbeautifier import beautify jsdata = beautify(get_data(api.jsstream)) return Response(jsdata, mimetype="text/javascript") app.api = api return app
def __init__(self): self.log = get_logger("api_mock") self.resources = {} self.jsstream = create_stream()
def main(): mod = Module() mod.__name__ = "test_module" stream = create_stream() for i in range(0, 1000): handle_creation(mod, stream)