Esempio n. 1
0
def update():
    import re
    with open("../data/comments.bin", "rb") as f:
        comments = Storage.load(f)

    store = Storage()
    for key, val in request.form.items():
        if "rating" in key:
            id = re.match(r"rating\[(?P<id>(\d+))\]", key).group("id")
            store.add_comment(comments[int(id) - 1].text, val)

    with open("../data/comments.bin", "wb") as f:
        import pickle
        pickle.dump(store.comments, f)

    return redirect("/")
Esempio n. 2
0
def update():
    import re
    with open("../data/comments.bin", "rb") as f:
        comments = Storage.load(f)

    store = Storage()
    for key, val in request.form.items():
        if "rating" in key:
            id = re.match(r"rating\[(?P<id>(\d+))\]", key).group("id")
            store.add_comment(comments[int(id)-1].text, val)

    with open("../data/comments.bin", "wb") as f:
        import pickle
        pickle.dump(store.comments, f)

    return redirect("/")
Esempio n. 3
0
def delete(id):
    with open("../data/comments.bin", "rb") as f:
        comments = Storage.load(f)

    comments.pop(int(id) - 1)
    with open("../data/comments.bin", "wb") as f:
        import pickle
        pickle.dump(comments, f)

    return redirect("/")
Esempio n. 4
0
def delete(id):
    with open("../data/comments.bin", "rb") as f:
        comments = Storage.load(f)

    comments.pop(int(id) - 1)
    with open("../data/comments.bin", "wb") as f:
        import pickle
        pickle.dump(comments, f)

    return redirect("/")
Esempio n. 5
0
def index():
    with open("../data/comments.bin", "rb") as f:
        comments = Storage.load(f)
    return render_template("comment_list.html", comments=comments)
Esempio n. 6
0
def index():
    with open("../data/comments.bin", "rb") as f:
        comments = Storage.load(f)
    return render_template("comment_list.html", comments=comments)