asco/app.py
Jacob 2cb11e4933 Initial commit.
Yeah I know there are a lot of nonessential files but w/e.
2024-12-17 01:39:52 -05:00

29 lines
902 B
Python

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)