Commits

Tarek Ziadé committed e5116ca

added a client

  • Participants
  • Parent commits 3b50575

Comments (0)

Files changed (1)

File errli/client.py

+""" Client lib
+"""
+import urllib2
+import json
+
+
+_SERVER = 'http://localhost:5000'
+_KEY = 'booba76'
+
+
+def shorten(url):
+    req = urllib2.Request(_SERVER, headers={'X-Short': _KEY})
+    req.get_method = lambda: 'POST'
+    req.add_data(url)
+    res = urllib2.urlopen(req).read()
+    res = json.loads(res)
+    return _SERVER + '/' + res['short']
+
+
+if __name__ == '__main__':
+    print shorten('http://test.com')
+
+