Tasks can now be queued from the web interface. Tasks are dispatched to the crawl server(s)

This commit is contained in:
Simon
2018-06-12 13:44:03 -04:00
parent 6d48f1f780
commit d61fd75890
14 changed files with 169 additions and 409 deletions

View File

@@ -1,16 +1,11 @@
from flask import Flask, request, abort, Response
import json
from crawl_server.task_manager import TaskManager, Task
from crawl_server.task_manager import TaskManager, Task, TaskResult
app = Flask(__name__)
tm = TaskManager("tm_db.sqlite3")
@app.route("/")
def hello():
return "Hello World!"
@app.route("/task/")
def get_tasks():
json_str = json.dumps([task.to_json() for task in tm.get_tasks()])
@@ -37,5 +32,18 @@ def task_put():
return abort(400)
@app.route("/task/completed", methods=["GET"])
def get_completed_tasks():
json_str = json.dumps([result.to_json() for result in tm.get_non_indexed_results()])
return json_str
@app.route("/task/current", methods=["GET"])
def get_current_tasks():
current_tasks = tm.get_current_tasks()
return current_tasks
if __name__ == "__main__":
app.run()
app.run(port=5001)