aboutsummaryrefslogtreecommitdiff
path: root/app/views.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-16 20:00:35 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-16 20:00:35 +0530
commita76126e01e3e8d6ed47a823636a809dad1e58283 (patch)
treefb13239dcb0a06aea267e68d63dc02a4bdf790ea /app/views.py
parentca50f9cb6943f7010ab2eec1a23cad7896d7b553 (diff)
added pubchem search
Diffstat (limited to 'app/views.py')
-rw-r--r--app/views.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/views.py b/app/views.py
index dfd33e2..142229b 100644
--- a/app/views.py
+++ b/app/views.py
@@ -14,6 +14,8 @@ from datetime import datetime,date
import json
import subprocess
+import requests
+
import logging
import logzero
from logzero import logger
@@ -100,6 +102,20 @@ def pubmed():
flash_errors(form)
return render_template('search.html',form=form)
+@app.route('/Compound-Search',methods=['GET','POST'])
+def pubchem():
+ form = PyMedSearch()
+
+ if request.method == 'POST' and form.validate_on_submit():
+ q = form.query.data
+ response = requests.get('https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/%s/property/Fingerprint2D,CanonicalSMILES,IsomericSMILES/JSON' % q.strip())
+ if response.status_code == 404:
+ return render_template('error.html',code="PC00",description=errors["PC00"])
+ search = response.json()["PropertyTable"]["Properties"]
+ print(search)
+ return render_template('search-pubchem.html',result=search,form=form)
+ return render_template('search-pubchem.html',form=form)
+
@app.route('/Status',methods=['GET','POST'])
def status():
taskStatusForm = statusForm()