mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Start work on views
This commit is contained in:
+16
-11
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
from queue import Queue
|
from queue import Queue, Empty
|
||||||
from flask import Flask, jsonify, request
|
from flask import Flask, jsonify, request
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
|
|
||||||
@@ -9,21 +9,24 @@ HOST_ADDRESS = "192.168.1.191"
|
|||||||
PORT_ADDRESS = 5000
|
PORT_ADDRESS = 5000
|
||||||
OUT_COMM_Q = Queue()
|
OUT_COMM_Q = Queue()
|
||||||
IN_COMM_Q = Queue()
|
IN_COMM_Q = Queue()
|
||||||
|
internal_q = Queue()
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route("/conjurer", methods=["POST"])
|
@app.route("/conjurer", methods=["POST"])
|
||||||
def answer_external_command():
|
def answer_external_command():
|
||||||
record = json.loads(request.data)
|
record = json.loads(request.data)
|
||||||
app.logger.info(record)
|
app.logger.info(record)
|
||||||
#if "UUID" in record and "QUERY" in record and "AUTHOR" in record:
|
|
||||||
# answer_data = "Query logged"
|
|
||||||
#return_data = (
|
|
||||||
# jsonify(isError=False, message="Success", statusCode=200, data=answer_data),
|
|
||||||
# 200,
|
|
||||||
#)
|
|
||||||
#return return_data
|
|
||||||
app.logger.info("DATA RECEIVED")
|
app.logger.info("DATA RECEIVED")
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
q_data = internal_q.get(block=False)
|
||||||
|
except Empty:
|
||||||
|
break
|
||||||
|
if q_data.uuid in record:
|
||||||
|
pass
|
||||||
|
|
||||||
return jsonify("SUCCESS")
|
return jsonify("SUCCESS")
|
||||||
|
|
||||||
@app.route("/conjurer", methods=["GET"])
|
@app.route("/conjurer", methods=["GET"])
|
||||||
@@ -52,13 +55,15 @@ def scan_queue(_logger):
|
|||||||
while True:
|
while True:
|
||||||
data = OUT_COMM_Q.get()
|
data = OUT_COMM_Q.get()
|
||||||
_logger.info(data)
|
_logger.info(data)
|
||||||
|
internal_q.put(data)
|
||||||
|
query_list.append(data)
|
||||||
|
|
||||||
def comm_subroutine(logger):
|
def comm_subroutine(logger):
|
||||||
#logger.setLevel(logging.DEBUG)
|
#logger.setLevel(logging.DEBUG)
|
||||||
logger.info("Started")
|
logger.info("Started")
|
||||||
threads = []
|
threads = []
|
||||||
#threads.append(threading.Thread(target=flask_debug, args=(logger,)))
|
threads.append(threading.Thread(target=flask_debug, args=(logger,)))
|
||||||
threads.append(threading.Thread(target=waitress_run, args=(logger,)))
|
#threads.append(threading.Thread(target=waitress_run, args=(logger,)))
|
||||||
threads.append(threading.Thread(target=scan_queue,args=(logger,)))
|
threads.append(threading.Thread(target=scan_queue,args=(logger,)))
|
||||||
|
|
||||||
for worker in threads:
|
for worker in threads:
|
||||||
|
|||||||
Reference in New Issue
Block a user