This commit is contained in:
√(noham)²
2024-03-03 15:52:50 +01:00
parent 5c5d9514ce
commit 828e481d1d
12 changed files with 353 additions and 37 deletions

View File

@@ -1,7 +1,7 @@
from flask import Flask, request, jsonify
from flask_cors import CORS
import json
#import hashlib
import hashlib
app = Flask(__name__)
CORS(app, resources={r"/music/*": {"origins": "http://*"}})
@@ -16,12 +16,12 @@ def set_content():
data = request.get_json()
user = data.get('user')
password = data.get('password')
if data['user'] in users and users[data['user']] == data['password']:
# if user in users and users[user] == hashlib.sha256(password.encode()).hexdigest():
if user in users and users[user] == hashlib.sha256(password.encode()).hexdigest():
# cache.clear()
cache.update(data)
cache.pop('user', None)
cache.pop('password', None)
return jsonify({'message': 'Content set successfully.'})
return jsonify({'message': f'Content set successfully.'})
else:
return jsonify({'message': 'Invalid user or password.'}), 401