Exemple #1
0
def freeze():
    """Freeze the viewer data using Frozen-Flask.
    
    Output data will be in the build/ directory."""
    viewer.app.config["FREEZER_RELATIVE_URLS"] = True

    freezer = Freezer(viewer.app)

    with click.progressbar(freezer.freeze_yield(),
                           item_show_func=lambda p: p.url
                           if p else 'Done!') as urls:
        for url in urls:
            pass
Exemple #2
0
# http://pythonhosted.org/Frozen-Flask/#api-reference
freezer = Freezer(
    app,
    # with_no_argument_rules=False
    # ignore all other url's
    log_url_for=False)


@freezer.register_generator
def all_urls():
    df = kipoi.get_source("kipoi").list_models()
    model = df.model
    urls = set()
    for m in model:
        while m:
            urls.add(m)
            m = os.path.dirname(m)
    groups = {x for x in urls if get_view(x, df)[0] == "group_list"}
    # exclude the final models
    groups = groups - set(model)

    return ["/", "/groups/"] + ["/groups/{0}/".format(x) for x in groups
                                ] + ["/models/{0}/".format(x) for x in urls]


if __name__ == '__main__':
    urls = list(freezer.all_urls())
    for x in tqdm(freezer.freeze_yield(), total=len(urls)):
        pass
    print("Done!")
Exemple #3
0
# -*- coding: utf-8 -*-
import click
import main
from flask_frozen import Freezer

freezer = Freezer(main.app)

if __name__ == '__main__':

    with click.progressbar(freezer.freeze_yield(),
                           item_show_func=lambda p: p.url
                           if p else 'Done!') as urls:
        for url in urls:
            # everything is already happening, just pass
            pass
Exemple #4
0
import sys

import click
from flask_frozen import Freezer

from website import create_app

# Call the application factory function to construct a Flask application
# instance using the development configuration
app = create_app()

# Create an instance of Freezer for generating the static files from
# the Flask application routes ('/', '/breakfast', etc.)
freezer = Freezer(app)


if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == "build":
        print("Freezing website")
        with click.progressbar(
            freezer.freeze_yield(), item_show_func=lambda p: p.url if p else "Done!"
        ) as urls:
            for url in urls:
                # everything is already happening, just pass
                pass
        shutil.copytree("./website/static/", "./docs/static/", dirs_exist_ok=True)

    else:
        port = int(os.environ.get("PORT", 5000))
        app.run(host="0.0.0.0", port=port)
Exemple #5
0
def freeze_build():
    freezer = Freezer(current_app)
    for l in freezer.freeze_yield():
        print(l)