Skip to content

Commit

Permalink
now change app/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kreynoldsf5 committed Apr 30, 2024
1 parent e382820 commit af5e690
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
25 changes: 19 additions & 6 deletions cloudapp/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def return_err(err):
'error': err.description
}

@app.route('/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
@app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
@app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
def echo():
"""
Echo the request headers and data
Expand All @@ -35,20 +36,26 @@ 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('/<env>/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
@app.route('/<env>/', 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)
Expand All @@ -62,7 +69,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

Expand Down
6 changes: 6 additions & 0 deletions cloudapp/app/templates/pretty_echo.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ <h1 class="mt-5">
&nbsp{{ request_env }}
</div>
</div>
<div class="card mt-3">
<div class="card-header">Info</div>
<div class="card-body json-output">
<pre><code class="json">{{ info | to_pretty_json }}</code></pre>
</div>
</div>
<div class="card mt-3">
<div class="card-header">Headers</div>
<div class="card-body json-output">
Expand Down

0 comments on commit af5e690

Please sign in to comment.