Skip to content

Commit

Permalink
next exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Reynolds committed Apr 30, 2024
1 parent 6126ae3 commit 96f3e1a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cloudapp/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def create_app():
def to_pretty_json(value):
return json.dumps(value, sort_keys=True, indent=4)

@app.errorhandler(401)
@app.errorhandler(404)
@app.errorhandler(500)
def return_err(err):
return {
'error': err.description
}

@app.route('/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])
def echo():
"""
Expand All @@ -33,6 +41,12 @@ def echo():
response['request_data'] = data
return jsonify(response)

@app.route('/<env>/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'])
def echo_html():
Expand Down

0 comments on commit 96f3e1a

Please sign in to comment.