From 379365f739a095071c4589f019cd57734b0a97b7 Mon Sep 17 00:00:00 2001 From: Helen Kosova Date: Fri, 25 May 2018 11:55:15 +0300 Subject: [PATCH 01/16] Set JSONIFY_PRETTYPRINT_REGULAR=True to pretty-print JSON responses --- httpbin/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/httpbin/core.py b/httpbin/core.py index 0a00a82..1e0799d 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -55,6 +55,7 @@ tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') app = Flask(__name__, template_folder=tmpl_dir) app.debug = bool(os.environ.get('DEBUG')) +app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True app.add_template_global('HTTPBIN_TRACKING' in os.environ, name='tracking_enabled') From 7e594911d9e7b290ec1a730c7dfb9b5648417c33 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Mon, 21 May 2018 17:27:59 +1000 Subject: [PATCH 02/16] Removed requirements.txt from MANIFEST.in. Signed-off-by: Brett Randall --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 9375654..37ce52d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ -include README.rst LICENSE AUTHORS requirements.txt test_httpbin.py +include README.rst LICENSE AUTHORS test_httpbin.py recursive-include httpbin/templates * recursive-include httpbin/static * From fae67e82bb99ea6f88009dd9e131084e13fee5b0 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Mon, 21 May 2018 17:34:25 +1000 Subject: [PATCH 03/16] Fixed README.[rst->md] path in MANIFEST.in. Signed-off-by: Brett Randall --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 37ce52d..1d1c3c2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ -include README.rst LICENSE AUTHORS test_httpbin.py +include README.md LICENSE AUTHORS test_httpbin.py recursive-include httpbin/templates * recursive-include httpbin/static * From 4a5e87e918133436300fd1bfc0b56e20ac2ec5b1 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Thu, 14 Jun 2018 15:22:07 +0200 Subject: [PATCH 04/16] Support more HTTP methods for /delay --- httpbin/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpbin/core.py b/httpbin/core.py index 0a00a82..e6d53de 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -1072,7 +1072,7 @@ def digest_auth(qop=None, user='user', passwd='passwd', algorithm='MD5', stale_a return response -@app.route('/delay/') +@app.route('/delay/', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'TRACE']) def delay_response(delay): """"Returns a delayed response (max of 10 seconds). --- From 7d4565afe6309e2f29979157e06486fb10f0b301 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Fri, 29 Jun 2018 10:33:32 +1000 Subject: [PATCH 05/16] Added a .dockerignore file to ignore Dockerfile, prevent it from breaking cache and being added to the image. --- .dockerignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9414382 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile From b4a37294dbb71ac56873b1aace385ebd28b61b31 Mon Sep 17 00:00:00 2001 From: Nathan West Date: Thu, 28 Jun 2018 18:43:03 -0700 Subject: [PATCH 06/16] Documented query parameters for drip --- httpbin/core.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/httpbin/core.py b/httpbin/core.py index 0a00a82..55862b0 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -1102,6 +1102,31 @@ def drip(): --- tags: - Dynamic data + parameters: + - in: query + name: duration + type: number + description: The amount of time (in seconds) over which to drip each byte + default: 2 + required: false + - in: query + name: numbytes + type: integer + description: The number of bytes to respond with + default: 10 + required: false + - in: query + name: code + type: integer + description: The response code that will be returned + default: 200 + required: false + - in: query + name: delay + type: number + description: The amount of time (in seconds) to delay before responding + default: 2 + required: false produces: - application/octet-stream responses: @@ -1124,7 +1149,7 @@ def drip(): pause = duration / numbytes def generate_bytes(): for i in xrange(numbytes): - yield u"*".encode('utf-8') + yield b"*" time.sleep(pause) response = Response(generate_bytes(), headers={ From d3d33de226ddbb6a93c4e1a5425bb98d4767f0f1 Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Fri, 29 Jun 2018 21:19:50 +1000 Subject: [PATCH 07/16] redirect_to: Added url and status_code as query-string parameters for SwaggerUI. Fixed #476. --- httpbin/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/httpbin/core.py b/httpbin/core.py index 0a00a82..4922a8d 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -511,9 +511,12 @@ def redirect_to(): produces: - text/html parameters: - - name: url + - in: query + name: url type: string - - name: status_code + required: true + - in: query + name: status_code type: int responses: 302: From dd2513ae5940bc104d8bc4a9cab24a80304bd1db Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Mon, 2 Jul 2018 15:04:44 +1000 Subject: [PATCH 08/16] redirect_to: split arg process for GET vs POST/PATCH/PUT, so the latter use formData for parameters. Fixed #476. POST/PUT only support formData body, not JSON. Note that PATCH parameters do not appear in Swagger 2 UI. --- httpbin/core.py | 56 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/httpbin/core.py b/httpbin/core.py index 4922a8d..ea0409b 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -510,20 +510,58 @@ def redirect_to(): - Redirects produces: - text/html - parameters: - - in: query - name: url - type: string - required: true - - in: query - name: status_code - type: int + get: + parameters: + - in: query + name: url + type: string + required: true + - in: query + name: status_code + type: int + post: + consumes: + - application/x-www-form-urlencoded + parameters: + - in: formData + name: url + type: string + required: true + - in: formData + name: status_code + type: int + required: false + patch: + consumes: + - application/x-www-form-urlencoded + parameters: + - in: formData + name: url + type: string + required: true + - in: formData + name: status_code + type: int + required: false + put: + consumes: + - application/x-www-form-urlencoded + parameters: + - in: formData + name: url + type: string + required: true + - in: formData + name: status_code + type: int + required: false responses: 302: description: A redirection. """ - args = CaseInsensitiveDict(request.args.items()) + argsDict = request.form.to_dict(flat=True) if request.method in ('POST', 'PATCH', 'PUT') else request.args.items() + args = CaseInsensitiveDict(argsDict) # We need to build the response manually and convert to UTF-8 to prevent # werkzeug from "fixing" the URL. This endpoint should set the Location From a578b69cc3acb95bbe82ee9265d67d51f1113608 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 09:55:10 -0400 Subject: [PATCH 09/16] now --- now.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 now.json diff --git a/now.json b/now.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/now.json @@ -0,0 +1 @@ +{} From 5e9eeecdcd40d94b498ece04e2d71a33e3d8d948 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 10:01:38 -0400 Subject: [PATCH 10/16] vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ec156a9..ea1169a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ .tox *.egg-info *.swp +.vscode/ From 665ec9710c060048dbdc15693ea955a9ace53e36 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 10:01:51 -0400 Subject: [PATCH 11/16] labels for dockerfile --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 681bcd7..541f4cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ FROM ubuntu:18.04 +LABEL name="httpbin" +LABEL version="0.9.0" +LABEL description="A simple HTTP service." +LABEL org.kennethreitz.vendor="Kenneth Reitz" + RUN apt update -y && apt install python3-pip -y EXPOSE 80 From fdad46da302eb1fd0023283e3c79a878c8b0a046 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 10:48:14 -0400 Subject: [PATCH 12/16] only https --- httpbin/core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httpbin/core.py b/httpbin/core.py index 0a00a82..fe100f0 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -83,8 +83,7 @@ template = { "host": "httpbin.org", # overrides localhost:5000 "basePath": "/", # base bash for blueprint registration "schemes": [ - "https", - "http" + "https" ], 'protocol': 'https', 'tags': [ From 4c3c25684157a773881fd98344c525a3793c3033 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 10:49:39 -0400 Subject: [PATCH 13/16] now.json --- now.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/now.json b/now.json index 0967ef4..b384fe9 100644 --- a/now.json +++ b/now.json @@ -1 +1,6 @@ -{} +{ + "regions": [ + "all" + ], + "alias": "httpbin.org" +} From 8f5464f5a3b8dbc3c00cd2245fb0cc09a4161929 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 10:57:10 -0400 Subject: [PATCH 14/16] updates --- httpbin/templates/index.html | 283 ++++++++++++++++++++++++++++------- now.json | 8 +- 2 files changed, 239 insertions(+), 52 deletions(-) diff --git a/httpbin/templates/index.html b/httpbin/templates/index.html index 7fbae03..5fed70c 100644 --- a/httpbin/templates/index.html +++ b/httpbin/templates/index.html @@ -1,70 +1,251 @@ + httpbin(1): HTTP Client Testing Service - - - + + + -{% include 'httpbin.1.html' %} - -{% if tracking_enabled %} - {% include 'trackingscripts.html' %} -{% endif %} + {% include 'httpbin.1.html' %} {% if tracking_enabled %} {% include 'trackingscripts.html' %} {% endif %} + diff --git a/now.json b/now.json index b384fe9..5d309f6 100644 --- a/now.json +++ b/now.json @@ -1,6 +1,12 @@ { + "name": "httpbin", "regions": [ "all" ], - "alias": "httpbin.org" + "alias": [ + "httpbin.org" + ], + "type": [ + "docker" + ] } From 6693e0d971a3ed8a50410431b9ea906091142c87 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 10:57:40 -0400 Subject: [PATCH 15/16] fix --- now.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/now.json b/now.json index 5d309f6..26fd17f 100644 --- a/now.json +++ b/now.json @@ -6,7 +6,5 @@ "alias": [ "httpbin.org" ], - "type": [ - "docker" - ] + "type": "docker" } From 390595e029e43a921a6a72c7c592a8da4f13114d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 4 Jul 2018 11:00:38 -0400 Subject: [PATCH 16/16] template --- httpbin/templates/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/httpbin/templates/index.html b/httpbin/templates/index.html index 5fed70c..0348536 100644 --- a/httpbin/templates/index.html +++ b/httpbin/templates/index.html @@ -207,10 +207,6 @@ text-align: right; float: right; } - - .scheme-container { - display: none !important; - }