From 7e8132e5df27d28747daffb5523492a168fd2f30 Mon Sep 17 00:00:00 2001 From: ImmyR Date: Thu, 8 Aug 2013 15:32:54 +0100 Subject: [PATCH] final thingy updated --- everything.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/everything.py b/everything.py index 9868248..0d6f76b 100644 --- a/everything.py +++ b/everything.py @@ -1,13 +1,20 @@ import json import urllib.request import cgitb +import sys +import cgi cgitb.enable() + print("Content-Type: application/json") print() +fields = cgi.FieldStorage() +if "term" not in fields: + print("[]") + sys.exit() -f = urllib.request.urlopen('http://gtr.rcuk.ac.uk/search/project.json?term=mouse') +f = urllib.request.urlopen('http://gtr.rcuk.ac.uk/search/project.json?term=%s' % (fields['term'])) s = f.read() data = json.loads(s.decode('utf-8')) f.close() @@ -41,8 +48,6 @@ organisations[orgid].append(details) -# print "%s gave %d pounds to %s for '%s'\n" % (funder, pounds, fundee, title) - results = list() for organisation in organisations.keys():