24 lines
825 B
Python
24 lines
825 B
Python
from __future__ import annotations
|
|
import json
|
|
from flask_restful import Resource
|
|
from flask import current_app as app, request
|
|
from typing import TYPE_CHECKING
|
|
import hashlib
|
|
|
|
if TYPE_CHECKING:
|
|
from modules.Archive.database import Database
|
|
|
|
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":
|
|
data = json.loads(request.data)
|
|
result = db.db.run_commands(data)
|
|
else:
|
|
result = None
|
|
else:
|
|
result = None
|
|
return db.wrap_query_response(result, mode="text") |