Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -72,14 +72,16 @@ def analyze():
|
|
72 |
# Get file ID from request
|
73 |
file_id = request.json.get("file_id")
|
74 |
log_debug("Received API request", file_id=file_id)
|
75 |
-
|
76 |
-
|
77 |
|
78 |
# Fetch file path from Supabase
|
79 |
file_data = supabase_client.table("files").select("file_path").eq("id", file_id).single().execute()
|
80 |
-
log_debug("Supabase file data response",
|
81 |
-
|
82 |
-
|
|
|
|
|
83 |
|
84 |
file_path = file_data.data["file_path"]
|
85 |
log_debug("File path retrieved from Supabase", file_path=file_path)
|
@@ -127,5 +129,6 @@ def analyze():
|
|
127 |
return jsonify({"error": str(e)}), 500
|
128 |
|
129 |
|
|
|
130 |
if __name__ == "__main__":
|
131 |
app.run(host="0.0.0.0", port=8000)
|
|
|
72 |
# Get file ID from request
|
73 |
file_id = request.json.get("file_id")
|
74 |
log_debug("Received API request", file_id=file_id)
|
75 |
+
if not file_id:
|
76 |
+
return jsonify({"error": "File ID is required"}), 400
|
77 |
|
78 |
# Fetch file path from Supabase
|
79 |
file_data = supabase_client.table("files").select("file_path").eq("id", file_id).single().execute()
|
80 |
+
log_debug("Supabase file data response", status_code=file_data.status_code, data=file_data.data)
|
81 |
+
|
82 |
+
# Check if the response is successful
|
83 |
+
if file_data.status_code != 200 or not file_data.data:
|
84 |
+
return jsonify({"error": "File not found or Supabase query failed"}), 404
|
85 |
|
86 |
file_path = file_data.data["file_path"]
|
87 |
log_debug("File path retrieved from Supabase", file_path=file_path)
|
|
|
129 |
return jsonify({"error": str(e)}), 500
|
130 |
|
131 |
|
132 |
+
|
133 |
if __name__ == "__main__":
|
134 |
app.run(host="0.0.0.0", port=8000)
|