|
|
from flask import Flask, jsonify, send_file |
|
|
import json |
|
|
import os |
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
@app.route("/") |
|
|
def index(): |
|
|
return "📘 Figure Detection Service Running: Visit /extract" |
|
|
|
|
|
@app.route("/extract", methods=["GET"]) |
|
|
def extract(): |
|
|
layout_path = "layout.json" |
|
|
if not os.path.exists(layout_path): |
|
|
return jsonify({"error": "layout.json not found"}), 404 |
|
|
|
|
|
with open(layout_path, "r", encoding="utf-8") as f: |
|
|
data = json.load(f) |
|
|
|
|
|
return jsonify(data) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
app.run(host="0.0.0.0", port=7860) |
|
|
|