diff --git a/cloudapp/app/app.py b/cloudapp/app/app.py index a824f16..7fc40d3 100644 --- a/cloudapp/app/app.py +++ b/cloudapp/app/app.py @@ -21,6 +21,7 @@ def return_err(err): 'error': err.description } + @app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) @app.route('/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def echo(): """ @@ -35,20 +36,27 @@ def echo(): print(e) response = { 'request_headers': headers, - 'request_env': app.config['site'] + 'env': app.config['site'], + 'info': { + 'method': request.method, + 'url': request.url, + 'path': request.path, + 'full_path': request.full_path + } } if data: response['request_data'] = data return jsonify(response) + @app.route('//', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) @app.route('//raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def env_echo(env): if env.lower() == app.config['site'].lower(): return echo() return jsonify({'error': 'Invalid environment'}) - @app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) - @app.route('/echo', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) + @app.route('/pretty', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) + @app.route('/pretty_echo', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def echo_html(): """ Same as /raw, just prettier""" headers = dict(request.headers) @@ -62,7 +70,13 @@ def echo_html(): data = request.form.to_dict() except Exception: pass - return render_template('pretty_echo.html', request_env=app.config['site'], request_headers=headers, request_data=data) + info = { + 'method': request.method, + 'url': request.url, + 'path': request.path, + 'full_path': request.full_path + } + return render_template('pretty_echo.html', request_env=app.config['site'], info=info, request_headers=headers, request_data=data) return app diff --git a/cloudapp/app/templates/pretty_echo.html b/cloudapp/app/templates/pretty_echo.html index 0ad7412..fe339ed 100644 --- a/cloudapp/app/templates/pretty_echo.html +++ b/cloudapp/app/templates/pretty_echo.html @@ -49,6 +49,12 @@

 {{ request_env }} +
+
Info
+
+
{{ info | to_pretty_json }}
+
+
Headers
diff --git a/labapp/app/app.py b/labapp/app/app.py index 0cdc0b6..8510986 100644 --- a/labapp/app/app.py +++ b/labapp/app/app.py @@ -174,8 +174,8 @@ def lb_aws(): ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") - url = f"https://{ns}.{app.config['base_url']}/raw" - data = cloudapp_fetch(url, 5, 'request_env', 'AWS') + url = f"https://{ns}.{app.config['base_url']}" + data = cloudapp_fetch(url, 5, 'env', 'AWS') return jsonify(status='success', data=data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) @@ -187,8 +187,8 @@ def lb_azure(): ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") - url = f"https://{ns}.{app.config['base_url']}/raw" - data = cloudapp_fetch(url, 5, 'request_env', 'Azure') + url = f"https://{ns}.{app.config['base_url']}" + data = cloudapp_fetch(url, 5, 'env', 'Azure') return jsonify(status='success', data=data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) @@ -203,8 +203,8 @@ def route1(): base_url = app.config['base_url'] aws_url = f"https://{ns}.{base_url}/aws/raw" azure_url = f"https://{ns}.{base_url}/azure/raw" - aws_data = cloudapp_fetch(aws_url, 5, 'request_env', 'AWS') - azure_data = cloudapp_fetch(azure_url, 5, 'request_env', 'Azure') + aws_data = cloudapp_fetch(aws_url, 5, 'env', 'AWS') + azure_data = cloudapp_fetch(azure_url, 5, 'env', 'Azure') data = { "aws": aws_data, "azure": azure_data @@ -221,10 +221,10 @@ def route2(): if not ns: raise LabException("Ephemeral NS not set") base_url = app.config['base_url'] - aws_url = f"https://{ns}.{base_url}/raw" - azure_url = f"https://{ns}.{base_url}/raw" - aws_data = cloudapp_fetch(aws_url, 5, 'request_env', 'AWS', headers={"X-MCN-lab": "aws"}) - azure_data = cloudapp_fetch(azure_url, 5, 'request_env', 'Azure', headers={"X-MCN-lab": "azure"}) + aws_url = f"https://{ns}.{base_url}/" + azure_url = f"https://{ns}.{base_url}/" + aws_data = cloudapp_fetch(aws_url, 5, 'env', 'AWS', headers={"X-MCN-lab": "aws"}) + azure_data = cloudapp_fetch(azure_url, 5, 'env', 'Azure', headers={"X-MCN-lab": "azure"}) data = { "aws": aws_data, "azure": azure_data diff --git a/labapp/app/markdown/lb.md b/labapp/app/markdown/lb.md index 0f48503..01f9d3f 100644 --- a/labapp/app/markdown/lb.md +++ b/labapp/app/markdown/lb.md @@ -42,7 +42,7 @@ Build an origin pool and load balancer based on the exercise requirements. #### **Test Criteria** ```http -GET https://eph-ns.mcn-lab.f5demos.com/raw HTTP/1.1 +GET https://eph-ns.mcn-lab.f5demos.com/ HTTP/1.1 Host: eph-ns.mcn-lab.f5demos.com { @@ -125,7 +125,7 @@ Create a new origin pool for the Azure cloud app. Reuse your load balancer. #### **Test Criteria** ```http -GET https://eph-ns.mcn-lab.f5demos.com/raw HTTP/1.1 +GET https://eph-ns.mcn-lab.f5demos.com/ HTTP/1.1 Host: eph-ns.mcn-lab.f5demos.com {