예제 #1
0
def detail():
    if request.method == "POST":
        target, proceed = Dispatcher.create_url(request.form.get("txtbox", ""))
        print(target)
        if proceed:
            schema = Dispatcher(target).create_schema()
        else:
            schema = Dispatcher.defaults()
    else:
        schema = Dispatcher.defaults()
    return render_template("detail.html", schema=schema)
예제 #2
0
def index():
    """ parse request.args for bucket and link
    if either is present, retrieve data accordingly
    if either is present, set active attribute to True
    return schema """
    # initialize empty lists so we dont raise errors
    buckets = []
    links = []
    # get list of buckets
    buckets = database2
    # parse args
    bucket, link = parse_view_args(request.args)
    if bucket:  # retrieve child links, set bucket to active
        for each in buckets:
            if each["id"] == bucket:
                each["active"] = True
                links = each["children"]
            else:
                each["active"] = False
    else:
        for each in buckets:
            each["active"] = False
    if link:  # create preview schema, set link to active
        for each in links:
            if each["id"] == link:
                each["active"] = True
                schema = Dispatcher(each["url"]).create_schema()
            else:
                each["active"] = False
    else:
        for each in links:
            each["active"] = False
        schema = Dispatcher.defaults()
    return render_template("index.html",
                           buckets=buckets,
                           links=links,
                           schema=schema)