Skip to content

Instantly share code, notes, and snippets.

@cosmic-byte
Created March 26, 2018 16:28
Show Gist options
  • Save cosmic-byte/0dfab5ff8c382607eff3dd71b10b9796 to your computer and use it in GitHub Desktop.
Save cosmic-byte/0dfab5ff8c382607eff3dd71b10b9796 to your computer and use it in GitHub Desktop.
from app.main import db
from app.main.model.blacklist import BlacklistToken
def save_token(token):
blacklist_token = BlacklistToken(token=token)
try:
# insert the token
db.session.add(blacklist_token)
db.session.commit()
response_object = {
'status': 'success',
'message': 'Successfully logged out.'
}
return response_object, 200
except Exception as e:
response_object = {
'status': 'fail',
'message': e
}
return response_object, 200
@austinjp
Copy link

Should the final return include a 200 code? Perhaps 500 would be more appropriate, since the exception would be raised by database operations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment