Skip to content

Commit

Permalink
ADD: verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
alguadam committed Oct 1, 2023
1 parent e64ce9d commit 7e74244
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions iebank_api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ def hello_world():
# app.logger.warn('This is a warning log message')
# app.logger.error('This is an error message')
# app.logger.critical('This is a critical message')
app.logger.debug('Route / called')
return 'Hello, World!'

@app.route('/skull', methods=['GET'])
def skull():
app.logger.debug('Route /skull GET called')
text = 'Hi! This is the BACKEND SKULL! 💀 '
text = text +'<br/>Database URL:' + db.session.bind.url.database
if db.session.bind.url.host:
Expand All @@ -28,6 +30,7 @@ def skull():

@app.route('/accounts', methods=['POST'])
def create_account():
app.logger.debug('Route /accounts POST called')
name = request.json['name']
currency = request.json['currency']
account = Account(name, currency)
Expand All @@ -37,23 +40,27 @@ def create_account():

@app.route('/accounts', methods=['GET'])
def get_accounts():
app.logger.debug('Route /accounts GET')
accounts = Account.query.all()
return {'accounts': [format_account(account) for account in accounts]}

@app.route('/accounts/<int:id>', methods=['GET'])
def get_account(id):
app.logger.debug('Route /accounts GET called with id: ' + id)
account = Account.query.get(id)
return format_account(account)

@app.route('/accounts/<int:id>', methods=['PUT'])
def update_account(id):
app.logger.debug('Route /accounts PUT called with id: ' + id)
account = Account.query.get(id)
account.name = request.json['name']
db.session.commit()
return format_account(account)

@app.route('/accounts/<int:id>', methods=['DELETE'])
def delete_account(id):
app.logger.debug('Route /accounts DELETE called with id: ' + id)
account = Account.query.get(id)
db.session.delete(account)
db.session.commit()
Expand Down

0 comments on commit 7e74244

Please sign in to comment.