Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- .gitattributes +1 -0
- app.py +50 -0
- share_now.png +3 -0
.gitattributes
CHANGED
|
@@ -40,3 +40,4 @@ img4.png filter=lfs diff=lfs merge=lfs -text
|
|
| 40 |
img5.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
img6.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
logo.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 40 |
img5.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
img6.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
logo.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
share_now.png filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify, send_file
|
| 2 |
+
from analysis import get_comprehensive_analysis, generate_html_report
|
| 3 |
+
from pdf_generator import generate_pdf
|
| 4 |
+
import os
|
| 5 |
+
import uuid
|
| 6 |
+
|
| 7 |
+
app = Flask(__name__)
|
| 8 |
+
|
| 9 |
+
@app.route("/analyze", methods=["POST"])
|
| 10 |
+
def analyze():
|
| 11 |
+
if "image" not in request.files:
|
| 12 |
+
return jsonify({"success": False, "error": "No image uploaded"}), 400
|
| 13 |
+
|
| 14 |
+
image_file = request.files["image"]
|
| 15 |
+
|
| 16 |
+
# Save temp image
|
| 17 |
+
temp_name = f"upload_{uuid.uuid4().hex}.jpg"
|
| 18 |
+
image_file.save(temp_name)
|
| 19 |
+
|
| 20 |
+
# Run AI analysis
|
| 21 |
+
analysis = get_comprehensive_analysis(temp_name)
|
| 22 |
+
if not analysis:
|
| 23 |
+
return jsonify({"success": False, "error": "Analysis failed"}), 500
|
| 24 |
+
|
| 25 |
+
# Generate HTML and PDF
|
| 26 |
+
html_path = generate_html_report(analysis, "new_report.html")
|
| 27 |
+
pdf_path = generate_pdf(html_path, "report.pdf")
|
| 28 |
+
|
| 29 |
+
# Delete input image
|
| 30 |
+
os.remove(temp_name)
|
| 31 |
+
|
| 32 |
+
# If user wants PDF, return file
|
| 33 |
+
if request.form.get("return_pdf") == "true":
|
| 34 |
+
return send_file(pdf_path, mimetype="application/pdf", as_attachment=True)
|
| 35 |
+
|
| 36 |
+
# JSON only
|
| 37 |
+
return jsonify({
|
| 38 |
+
"success": True,
|
| 39 |
+
"analysis": analysis,
|
| 40 |
+
"pdf_ready": True
|
| 41 |
+
})
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
@app.route("/")
|
| 45 |
+
def home():
|
| 46 |
+
return "YOUV.AI Flask API is running!"
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
app.run(host="0.0.0.0", port=7860)
|
| 50 |
+
|
share_now.png
ADDED
|
Git LFS Details
|