Commit 290193d7 authored by Mikaël Salson's avatar Mikaël Salson

proxy.py: refactor

extract IMGT specific part, to have a more generic function that could be used elsewhere
parent 19df7b47
......@@ -10,17 +10,20 @@ if request.env.http_origin:
def index():
return gluon.contrib.simplejson.dumps("index()")
def imgt():
def proxy_request(url, headers):
if request.env.request_method == "POST":
payload = dict(request.post_vars)
if 'Session' in payload.keys():
del payload['Session']
response = requests.post("http://www.imgt.org/IMGT_vquest/analysis", data=payload)
response = requests.post(url, headers = headers, data=payload)
if response.status_code == requests.codes.ok:
return response
return gluon.contrib.simplejson.dumps("the site returned an invalid response")
return gluon.contrib.simplejson.dumps("improper method")
def imgt():
return proxy_request("http://www.imgt.org/IMGT_vquest/analysis")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment