from flask import Flask, redirect, render_template, request, url_for import fit app = Flask(__name__) @app.route("/", methods=("GET", "POST")) def index(): if request.method == "POST": title = request.form["title"] embedding = fit.get(title); #nclose = request.form["nclose"] percent = fit.percent(embedding); closest = fit.closest(embedding, 10); tprob = closest[1] return redirect(url_for("index", tprob=closest[1], result=percent, title=title, closest=closest[0])) result = request.args.get("result") title = request.args.get("title") closest = request.args.get("closest") #nclose = request.args.get("nclose") tprob = request.args.get("tprob") if title == None: title = "" #if nclose == None: nclose = 10 return render_template("index.html", tprob=tprob, result=result, title=title, closest=closest)