数据看板
This commit is contained in:
44
app.py
44
app.py
@@ -1,3 +1,4 @@
|
||||
import io
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
@@ -15,6 +16,15 @@ from auth_service import (
|
||||
)
|
||||
from config import Config
|
||||
from database import init_database
|
||||
from ocr_dashboard_service import (
|
||||
get_result_matches as get_ocr_result_matches,
|
||||
get_summary as get_ocr_dashboard_summary,
|
||||
list_batches as list_ocr_batches,
|
||||
list_collections as list_ocr_collections,
|
||||
list_evidences as list_ocr_evidences,
|
||||
export_evidences as export_ocr_evidences,
|
||||
list_results as list_ocr_results,
|
||||
)
|
||||
from acceptance_service import (
|
||||
create_acceptance_task,
|
||||
get_acceptance_resources,
|
||||
@@ -298,6 +308,40 @@ def create_app() -> Flask:
|
||||
def resume_project_acceptance_task(task_id: str):
|
||||
return jsonify({"data": resume_acceptance_task(task_id), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/batches", methods=["GET"])
|
||||
def query_ocr_dashboard_batches():
|
||||
return jsonify({"data": list_ocr_batches(), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/batches/<batch_key>/collections", methods=["GET"])
|
||||
def query_ocr_dashboard_collections(batch_key: str):
|
||||
return jsonify({"data": list_ocr_collections(batch_key), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/summary", methods=["GET"])
|
||||
def query_ocr_dashboard_summary():
|
||||
return jsonify({"data": get_ocr_dashboard_summary(
|
||||
request.args.get("batch_key", "").strip(),
|
||||
request.args.get("collection_key", "").strip(),
|
||||
), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/results", methods=["GET"])
|
||||
def query_ocr_dashboard_results():
|
||||
return jsonify({"data": list_ocr_results(request.args.to_dict()), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/results/<int:result_id>/matches", methods=["GET"])
|
||||
def query_ocr_dashboard_result_matches(result_id: int):
|
||||
return jsonify({"data": get_ocr_result_matches(result_id), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/evidences", methods=["GET"])
|
||||
def query_ocr_dashboard_evidences():
|
||||
return jsonify({"data": list_ocr_evidences(request.args.to_dict()), "request_id": g.request_id})
|
||||
|
||||
@app.route("/api/v1/data-dashboard/ocr/evidences/export", methods=["GET"])
|
||||
def export_ocr_dashboard_evidences():
|
||||
payload, filename, count = export_ocr_evidences(request.args.to_dict())
|
||||
response = send_file(payload, mimetype="application/zip", as_attachment=True, download_name=filename)
|
||||
response.headers["X-Evidence-Count"] = str(count)
|
||||
return response
|
||||
|
||||
@app.route("/api/v1/tasks", methods=["GET"])
|
||||
def query_research_tasks():
|
||||
result = list_tasks(
|
||||
|
||||
Reference in New Issue
Block a user