harbor run -t openthoughts/tasktrove-exp-rpt-curriculum-easy-curriculum-easy-0258harbor download openthoughts/tasktrove-exp-rpt-curriculum-easy-curriculum-easy-0258Goal Create a tiny Flask app that exposes a /predict endpoint which classifies an uploaded image using a very simple heuristic.
Where to implement
What to build (simplified)
Output format
Dependencies
Skeleton / Partial implementation (to help you get started)
# /app/__init__.py
from flask import Flask, request, jsonify
# 1) Create the app object to be imported as `app`
app = Flask(__name__)
# 2) Lightweight classifier (as requested)
def classify_image(image_bytes: bytes, filename: str) -> str:
# Hint: use a simple substring check on the filename
if "otter" in filename.lower():
return "otter"
return "unknown"
# 3) /predict endpoint
@app.route("/predict", methods=["POST"])
def predict():
# Hint: expect a file field named "file"
if "file" not in request.files:
return jsonify({"error": "No file provided"}), 400
f = request.files["file"]
image_bytes = f.read()
class_name = classify_image(image_bytes, f.filename)
return jsonify({"class_name": class_name})
# Optional: allow running directly for local testing
if __name__ == "__main__":
app.run(debug=True)
Hints
Acceptance criteria aligned with tests