From 787735cf8a9fd6647a8f617233fe2f4ff0ee51b3 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Wed, 14 Mar 2012 01:39:39 -0700 Subject: cloudant URL and AUTH extracted --- app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index e8cabe8..e379cb1 100644 --- a/app.py +++ b/app.py @@ -6,23 +6,26 @@ import string from bottle import post, route, request, run, static_file, template +CLOUDANT_BASE = 'https://pinkyswear.cloudant.com/pinkyswear/' +CLOUDANT_AUTH = ('pinkyswear', 'abc123') + @route('/') def index(name='home'): return template('index.html', sig=None) @route('/s/:id') def sig(id='home'): - url = 'https://pinkyswear.cloudant.com/pinkyswear/%s' % id - r = requests.get(url, auth=('pinkyswear', 'abc123')) + url = CLOUDANT_BASE + id + r = requests.get(url, auth=CLOUDANT_AUTH) sig = json.loads(r.content)['s'] return template('index.html', sig=sig) @post('/s') def sig(id='home'): data = json.dumps({ 's' : request.POST['output'] }) - url = 'https://pinkyswear.cloudant.com/pinkyswear/' + url = CLOUDANT_BASE headers = { 'content-type' : 'application/json' } - r = requests.post(url, auth=('pinkyswear', 'abc123'), data=data, headers=headers) + r = requests.post(url, auth=CLOUDANT_AUTH, data=data, headers=headers) return r.content run(host='localhost', port=8000) -- cgit v1.3.1