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')
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')
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')
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')
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()
def borua_home(): return render_template('home.html', tree_list=TreeList.objects())
def hello_world(): return render_template("home.html", tree_list=TreeList.objects())