feat: add /devices endpoint

This commit is contained in:
2026-04-28 23:41:13 +02:00
parent 45773571aa
commit 1391e34e69
3 changed files with 37 additions and 1 deletions
+8 -1
View File
@@ -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)