db: api to get all entires

This commit is contained in:
Swapnil 2024-01-30 22:31:49 +05:30
parent c1b216dd11
commit 19af4bff34
Signed by: swapnil
GPG Key ID: 58029C48BB100574

View File

@ -107,5 +107,22 @@ def update_token_by_id(id):
db.session.commit()
return '', 204
# get all tokens
@app.route('/token/all', methods=['GET'])
def get_all_tokens():
tokens = Token.query.all()
tokens_info = [{
'id': token.id,
'email': token.email,
'access_token': token.access_token,
'refresh_token': token.refresh_token,
'expiration_seconds': int(token.expiration_seconds),
'readwise_api_key': token.readwise_api_key,
'active': token.active,
'created_at': int(token.created_at.timestamp()),
'updated_at': int(token.updated_at.timestamp())
} for token in tokens]
return jsonify({'tokens': tokens_info}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)