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. 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() diff --git a/httpbin/helpers.py b/httpbin/helpers.py index ef146e9..4c74101 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -25,8 +25,7 @@ ASCII_ART = """ `\"\"\"` """ -REDIRECT_LOCATION = 'http://httpbin.org/redirect/1' - +REDIRECT_LOCATION = '/redirect/1' def get_files(): @@ -53,11 +52,19 @@ def get_dict(*keys, **extras): assert all(map(_keys.__contains__, keys)) + data = request.data + form = request.form + + if len(form) == 1 and not data: + if not form.values().pop(): + data = form.keys().pop() + form = None + 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()