File size: 897 Bytes
1e08de6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)