CountryCode JSON now is only grabbed once per server run

pull/47/head
Hannah Ward 2016-08-17 09:51:16 +01:00
parent 317f820bbf
commit 4ba86d4fa3
No known key found for this signature in database
GPG Key ID: BA89E572EE1B4C5F
1 changed files with 3 additions and 2 deletions

View File

@ -20,7 +20,10 @@ common_tlds = {"com":"Commercial (Worldwide)",
"gov":"Government (USA)"
}
codes = requests.get("http://www.geognos.com/api/en/countries/info/all.json").json()
def handler(q=False):
global codes
if q is False:
return False
request = json.loads(q)
@ -34,8 +37,6 @@ def handler(q=False):
val = common_tlds[ext]
else:
# Retrieve a json full of country info
codes = requests.get("http://www.geognos.com/api/en/countries/info/all.json").json()
if not codes["StatusMsg"] == "OK":
val = "Unknown"
else: