From e9c24ce3442682f099bf3ceb003fd6a5f3e377b7 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 16 Feb 2024 18:43:50 +0300 Subject: pep8 formatting --- gn2/wqflask/views.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'gn2') diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 854d2621..cc212980 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -265,28 +265,26 @@ def gsearchtable(): @app.route("/gnqna", methods=["POST", "GET"]) def gnqna(): - - if request.method == "POST": try: def __error__(resp): return resp.json() - def error_page(error_msg): - return render_template("gnqa_errors.html",error = error_msg) + return render_template("gnqa_errors.html", error=error_msg) + def __success__(resp): - return render_template("gnqa_answer.html", **{"gn_server_url":GN3_LOCAL_URL,**(resp.json())}) - if user_logged_in(): + return render_template("gnqa_answer.html", **{"gn_server_url": GN3_LOCAL_URL, **(resp.json())}) + if not user_logged_in(): return error_page("Please Login/Register to Genenetwork to access this Service") token = session_info()["user"]["token"].either( - lambda err: err, lambda tok: tok["access_token"]) + lambda err: err, lambda tok: tok["access_token"]) return monad_requests.post( urljoin(GN3_LOCAL_URL, "/api/llm/gnqna"), json=dict(request.form), headers={ - "Authorization":f"Bearer {token}" + "Authorization": f"Bearer {token}" } ).then( lambda resp: resp @@ -299,7 +297,7 @@ def gnqna(): "/api/llm/get_hist_names") ).then( lambda resp: resp - ).either(lambda x: [], lambda x: x.json()["prev_queries"])) + ).either(lambda x: [], lambda x: x.json()["prev_queries"])) return render_template("gnqa.html", prev_queries=prev_queries) @@ -308,12 +306,9 @@ def gnqna(): def gnqna_hist(search_term): # todo add token validation - response = monad_requests.get(urljoin(GN3_LOCAL_URL,f"/api/llm/historys/{search_term}")).then(lambda resp :resp).either( - lambda x: x.json(),lambda x : x.json()) - return render_template("gnqa_answer.html",**{"gn_server_url":GN3_LOCAL_URL,**response}) - - - + response = monad_requests.get(urljoin(GN3_LOCAL_URL, f"/api/llm/historys/{search_term}")).then(lambda resp: resp).either( + lambda x: x.json(), lambda x: x.json()) + return render_template("gnqa_answer.html", **{"gn_server_url": GN3_LOCAL_URL, **response}) @app.route("/gsearch_updating", methods=('POST',)) -- cgit v1.2.3