Esempio n. 1
0
def deltree():
    if request.method == "GET":
        return render_template('deltree.html')
    elif request.method == "POST":
        new_tree1 = TreeList.objects(title=request.form["title"]).first()
        if new_tree1 is not None:
            new_tree1.delete()
        return render_template('deltree.html')
Esempio n. 2
0
def addtree():
    if request.method == "GET":
        return render_template('addtree.html')
    elif request.method == "POST":
        file = request.files["source"]
        if file:
            filename = secure_filename(file.filename)
            if os.path.join(app.config["UPLOAD_PATH"], filename):
                name_index = 0
                # home.png # a.c.b
                original_name = filename.split(".")[0]  #home
                original_extend = filename.split(".")[1]  #png
                while os.path.exists(
                        os.path.join(app.config["UPLOAD_PATH"], filename)):
                    name_index += 1
                    filename = "{0} ({1}).{2}".format(original_name,
                                                      name_index,
                                                      original_extend)
            file.save(os.path.join(app.config["UPLOAD_PATH"], filename))
        new_tree = TreeList()
        new_tree.src = url_for("uploads_file", filename=filename)
        new_tree.title = request.form["title"]
        new_tree.description = request.form["description"]
        new_tree.save()
        return render_template('addtree.html')
Esempio n. 3
0
def updatetree():
    if request.method == "GET":
        return render_template('updatetree.html')
    elif request.method == "POST":
        new_tree = TreeList.objects(title=request.form["title"]).first()
        if new_tree is not None:
            new_tree.description = request.form("descriptionupdate")
            new_tree.save()
            return render_template('updatetree.html')
Esempio n. 4
0
def addtree():
    if request.method == "GET":
        return render_template('addtree.html')
    elif request.method == "POST":
        new_tree = TreeList()
        new_tree.src = request.form["source"]
        new_tree.title = request.form["title"]
        new_tree.description = request.form["description"]
        new_tree.save()
        return render_template('addtree.html')
Esempio n. 5
0
def addtree():
    if request.method == "GET":
        return render_template('addtree.html')
    elif request.method == "POST":
        new_tree = TreeList()
        new_tree.src = request.form["source"]
        new_tree.title = request.form["title"]
        new_tree.description = request.form["description"]
        if
        new_tree.save()
        return render_template('addtree.html')

@app.route('/home')
def borua_home():
    return render_template('home.html', tree_list=TreeList.objects())


if __name__ == '__main__':
    app.run()
Esempio n. 6
0
def borua_home():
    return render_template('home.html', tree_list=TreeList.objects())
Esempio n. 7
0
def hello_world():
    return render_template("home.html", tree_list=TreeList.objects())