added commands (test)
This commit is contained in:
parent
2623106212
commit
fb4ad30d03
|
@ -4,6 +4,8 @@ from flask import Flask
|
|||
|
||||
from .databaseController import DatabaseController
|
||||
from .endpoints.query import Query, QueryOld
|
||||
from .endpoints.command import Command, CommandOld
|
||||
from .endpoints.commands import Commands, CommandsOld
|
||||
from .endpoints.post import GetPost, GetPostOld
|
||||
from .endpoints.posts import GetPosts, GetPostsOld
|
||||
from .endpoints.new_query import NewQuery, NewQueryOld
|
||||
|
@ -28,6 +30,8 @@ class Database:
|
|||
if database_name == "Archive":
|
||||
api.add_resource(Query, "/Archive/Query")
|
||||
api.add_resource(NewQuery, "/Archive/NewQuery")
|
||||
api.add_resource(Command, "/Archive/Command")
|
||||
api.add_resource(Commands, "/Archive/Commands")
|
||||
api.add_resource(GetPost, "/Archive/GetPost/<id>")
|
||||
api.add_resource(GetPosts, "/Archive/GetPosts")
|
||||
api.add_resource(GetPostsCount, "/Archive/GetPosts/Count")
|
||||
|
@ -36,6 +40,8 @@ class Database:
|
|||
elif database_name == "ArchiveOld":
|
||||
api.add_resource(QueryOld, "/ArchiveOld/Query")
|
||||
api.add_resource(NewQueryOld, "/ArchiveOld/NewQuery")
|
||||
api.add_resource(CommandOld, "/Archive/Command")
|
||||
api.add_resource(CommandsOld, "/Archive/Commands")
|
||||
api.add_resource(GetPostOld, "/ArchiveOld/GetPost/<id>")
|
||||
api.add_resource(GetPostsOld, "/ArchiveOld/GetPosts")
|
||||
api.add_resource(GetPostsCountOld, "/ArchiveOld/GetPosts/Count")
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
from __future__ import annotations
|
||||
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 Command(Resource):
|
||||
def post(self):
|
||||
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)
|
||||
else:
|
||||
result = None
|
||||
else:
|
||||
result = None
|
||||
return db.wrap_query_response(result, mode="text")
|
||||
|
||||
class CommandOld(Resource):
|
||||
def post(self):
|
||||
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)
|
||||
else:
|
||||
result = None
|
||||
else:
|
||||
result = None
|
||||
return db.wrap_query_response(result, mode="text")
|
|
@ -0,0 +1,45 @@
|
|||
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):
|
||||
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)
|
||||
else:
|
||||
result = None
|
||||
else:
|
||||
result = None
|
||||
return db.wrap_query_response(result, mode="text")
|
||||
|
||||
class CommandsOld(Resource):
|
||||
def post(self):
|
||||
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)
|
||||
else:
|
||||
result = None
|
||||
else:
|
||||
result = None
|
||||
return db.wrap_query_response(result, mode="text")
|
Loading…
Reference in New Issue