added commands

This commit is contained in:
katboi01 2025-01-17 12:10:15 +01:00
parent fb4ad30d03
commit fee0ecfe75
2 changed files with 8 additions and 18 deletions

View File

@ -9,15 +9,13 @@ if TYPE_CHECKING:
class Command(Resource):
def post(self):
db : Database = app.databases["Archive"]
auth = request.headers.get('auth')
if auth is not None:
hash_obj = hashlib.sha256(auth.encode('utf-8'))
if hash_obj.hexdigest() == "63a3b0dba950e1015a110486518e5ceff8cff415041aba3dedb8dc5aa3b3dd16":
db : Database = app.databases["Archive"]
query = request.data.decode("utf-8")
print("auth success")
print(query)
#result = db.db.run_command(query)
result = db.db.run_command(query)
else:
result = None
else:
@ -26,15 +24,13 @@ class Command(Resource):
class CommandOld(Resource):
def post(self):
db : Database = app.databases["ArchiveOld"]
auth = request.headers.get('auth')
if auth is not None:
hash_obj = hashlib.sha256(auth.encode('utf-8'))
if hash_obj.hexdigest() == "63a3b0dba950e1015a110486518e5ceff8cff415041aba3dedb8dc5aa3b3dd16":
db : Database = app.databases["ArchiveOld"]
query = request.data.decode("utf-8")
print("auth success")
print(query)
#result = db.db.run_command(query)
result = db.db.run_command(query)
else:
result = None
else:

View File

@ -10,16 +10,13 @@ if TYPE_CHECKING:
class Commands(Resource):
def post(self):
db : Database = app.databases["Archive"]
auth = request.headers.get('auth')
if auth is not None:
hash_obj = hashlib.sha256(auth.encode('utf-8'))
if hash_obj.hexdigest() == "63a3b0dba950e1015a110486518e5ceff8cff415041aba3dedb8dc5aa3b3dd16":
db : Database = app.databases["Archive"]
data = json.loads(request.data)
print("auth success")
print(data)
result = "ok"
#result = db.db.run_commands(data)
result = db.db.run_commands(data)
else:
result = None
else:
@ -28,16 +25,13 @@ class Commands(Resource):
class CommandsOld(Resource):
def post(self):
db : Database = app.databases["ArchiveOld"]
auth = request.headers.get('auth')
if auth is not None:
hash_obj = hashlib.sha256(auth.encode('utf-8'))
if hash_obj.hexdigest() == "63a3b0dba950e1015a110486518e5ceff8cff415041aba3dedb8dc5aa3b3dd16":
db : Database = app.databases["ArchiveOld"]
data = json.loads(request.data)
print("auth success")
print(data)
result = "ok"
#result = db.db.run_commands(data)
result = db.db.run_commands(data)
else:
result = None
else: