From ecf69607aed3269b27560de0eae82638ff3c1b4a Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 22:12:35 -0400 Subject: [PATCH 1/9] HTTP Request & Response Service. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cdcdc8b..bf5528f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -httpbin(1): HTTP Client Testing Service -======================================= +httpbin(1): HTTP Request & Response Service +=========================================== Freely hosted in both [HTTP](http://httpbin.org) and [HTTPS](https://httpbin.ep.io) flavors. From 30d0c4aba845ea89591cf8a63274bf67f2484ba0 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:18:49 -0400 Subject: [PATCH 2/9] will it blend? --- httpbin/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index ef146e9..00e29ea 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -25,8 +25,8 @@ ASCII_ART = """ `\"\"\"` """ -REDIRECT_LOCATION = 'http://httpbin.org/redirect/1' - +REDIRECT_LOCATION = '/redirect/1' +# TODO: url_for. def get_files(): From 882b28faec902e3166b8a65ccb5a3d8f1fb45211 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:20:39 -0400 Subject: [PATCH 3/9] indeed it does. --- httpbin/helpers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index 00e29ea..0cff86c 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -26,7 +26,6 @@ ASCII_ART = """ """ REDIRECT_LOCATION = '/redirect/1' -# TODO: url_for. def get_files(): From 35e2dafbfe3d063b9bda99182b819fa9a8c24d85 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:32:09 -0400 Subject: [PATCH 4/9] not all posts are form data, flask... --- httpbin/helpers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index 0cff86c..4f67319 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -52,11 +52,19 @@ def get_dict(*keys, **extras): assert all(map(_keys.__contains__, keys)) + data = request.data + form = request.form + + if len(form) == 1: + if not form.values.pop(): + form = None + data = form.keys().pop() + d = dict( url=request.url, args=request.args, - form=request.form, - data=request.data, + form=form, + data=data, origin=request.remote_addr, headers=get_headers(), files=get_files() From aafe99017518aaa439ffe459c27f549ea17b52c6 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:37:39 -0400 Subject: [PATCH 5/9] whoops --- httpbin/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index 4f67319..cf6731b 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -57,8 +57,8 @@ def get_dict(*keys, **extras): if len(form) == 1: if not form.values.pop(): - form = None data = form.keys().pop() + form = None d = dict( url=request.url, From 1985a205e1aa2f3fdea072c383215d3fa4e3bfcb Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:38:13 -0400 Subject: [PATCH 6/9] keep your hands to yourself --- httpbin/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index cf6731b..0a4f0a1 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -55,7 +55,7 @@ def get_dict(*keys, **extras): data = request.data form = request.form - if len(form) == 1: + if len(form) == 1 and not len(data): if not form.values.pop(): data = form.keys().pop() form = None From 1bf005af45ddee23a07ab32e599932f76961c57f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:40:15 -0400 Subject: [PATCH 7/9] None should really have __len__ --- httpbin/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index 0a4f0a1..c6e60b0 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -55,7 +55,7 @@ def get_dict(*keys, **extras): data = request.data form = request.form - if len(form) == 1 and not len(data): + if len(form) == 1 and not data: if not form.values.pop(): data = form.keys().pop() form = None From ebe2a5ab52a92a3d0ff978156edc176c6e80ecd1 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 15 Jun 2011 23:57:18 -0400 Subject: [PATCH 8/9] fabfile upgrades --- fabfile.py | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/fabfile.py b/fabfile.py index 2f73292..990f2e8 100644 --- a/fabfile.py +++ b/fabfile.py @@ -6,6 +6,7 @@ from fabric.api import * CMD_TEMPLATE = '{0}' +EPIO_TEMPLATE = 'epio {0}' def _run(cmd): @@ -24,17 +25,51 @@ def docs(): os.system("cat README.md|sed 's/(http:\/\/httpbin.org\//(\//'|ronn -5 -f --style 80c --pipe > ./httpbin/templates/httpbin.1.html") +def epio(cmd): + """Runs given command on EPIO.""" + + c = EPIO_TEMPLATE.format(cmd) + + print c + + os.system(c) + + + def prod(): """Runs all command on the production instance.""" global CMD_TEMPLATE + global EPIO_TEMPLATE - CMD_TEMPLATE = 'epio run_command {0}' + CMD_TEMPLATE = 'epio run_command {0} -a httpbin' + EPIO_TEMPLATE = 'epio {0} -a httpbin ' + + +def stag(): + """Runs all command on the staging instance.""" + global CMD_TEMPLATE + global EPIO_TEMPLATE + + CMD_TEMPLATE = 'epio run_command {0} -a httpbin-staging' + EPIO_TEMPLATE = 'epio {0} -a httpbin-staging ' def push(): - """Deploys the application""" + """Pushes the application""" docs() - prod() - local('epio upload') + epio('upload') + +def stage(): + """Deploys the application.""" + + stag() + push() + + +def deploy(): + """Deploys the application.""" + + prod() + push() From 9c0d61b0b0b990030de4f9e4958b6662f022a6d1 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 16 Jun 2011 00:12:03 -0400 Subject: [PATCH 9/9] whoops --- httpbin/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index c6e60b0..4c74101 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -56,7 +56,7 @@ def get_dict(*keys, **extras): form = request.form if len(form) == 1 and not data: - if not form.values.pop(): + if not form.values().pop(): data = form.keys().pop() form = None