Spaces:
Sleeping
Sleeping
File size: 2,334 Bytes
dcb132a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
import datetime
import flask
import src.functions.config
configBP = flask.Blueprint("config", __name__)
import main
@configBP.route("/api/v1/config", methods=["GET", "POST"])
async def configFunction():
secret = flask.request.args.get("secret") # SECRET
config = src.functions.config.readConfig()
if flask.request.method == "GET":
if secret == config.get("secret_key"):
return (
flask.jsonify(
{
"code": 200,
"content": config,
"message": "Config authentication completed successfully.",
"success": True,
}
),
200,
)
else:
return (
flask.jsonify(
{
"code": 401,
"message": "The secret key provided was incorrect.",
"success": False,
}
),
401,
)
elif flask.request.method == "POST":
if secret == None:
secret = ""
if secret == config.get("secret_key"):
data = flask.request.json
data["token_expiry"] = str(datetime.datetime.utcnow())
if data.get("category_list") != config.get("category_list"):
src.functions.config.updateConfig(data)
main.threaded_metadata()
else:
src.functions.config.updateConfig(data)
return (
flask.jsonify(
{
"code": 200,
"content": None,
"message": "libDrive is updating your config",
"success": True,
}
),
200,
)
else:
return (
flask.jsonify(
{
"code": 401,
"content": None,
"message": "The secret key provided was incorrect.",
"success": False,
}
),
401,
)
|