from flask import Flask, render_template, request,Response,send_file import io import controller.object_detection as object_detection_controller app = Flask(__name__) @app.route("/", methods = ['GET']) def home_page(): return render_template('home.html') @app.route("/detect-image", methods = ['POST']) def detect_image(): if "image" not in request.files: return {"error": "No image file provided"}, 400 file = request.files["image"] return object_detection_controller.detect_image(file) @app.route("/detect-video", methods = ['POST']) def detect_video(): if "video" not in request.files: return {"error": "No video file provided"}, 400 file = request.files["video"] video_bytes = object_detection_controller.detect_video(file) return Response(video_bytes, mimetype='video/mp4') if __name__ == '__main__': app.run(debug=True)