feat: add /devices endpoint
This commit is contained in:
@@ -7,8 +7,10 @@ import logging
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
import db
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['JWT_SECRET_KEY'] = 'secret' # TODO change and load from a secrets store
|
||||
app.config['JWT_SECRET_KEY'] = 'secret' # TODO change and load from a secrets store (should be over 32 bytes long)
|
||||
app.config['JWT_ACCESS_TOKEN_EXPIRES'] = timedelta(hours=1)
|
||||
app.config['JWT_REFRESH_TOKEN_EXPIRES'] = timedelta(days=30)
|
||||
flask_bcrypt = Bcrypt(app)
|
||||
@@ -60,3 +62,8 @@ def verify_token():
|
||||
def refresh_token():
|
||||
return make_response(jsonify({"access_token": create_access_token(identity=get_jwt_identity())}), 200)
|
||||
|
||||
|
||||
@app.route("/devices", methods=["GET"])
|
||||
@jwt_required()
|
||||
def get_all_devices():
|
||||
return make_response(jsonify([d.to_dict() for d in db.get_all_devices(cur)]), 200)
|
||||
|
||||
Reference in New Issue
Block a user