-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
32 lines (26 loc) · 825 Bytes
/
server.py
File metadata and controls
32 lines (26 loc) · 825 Bytes
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
32
# app.py
from flask import Flask, request, jsonify, send_file
from flask_cors import CORS, cross_origin
from detect_face import process_image
app = Flask(__name__)
cors = CORS(app)
@app.route('/detect', methods=['POST', 'OPTIONS'])
@cross_origin()
def detect():
if request.method == 'OPTIONS':
return jsonify({}), 200
if 'image' not in request.files:
return jsonify({'error': 'No image provided'}), 400
file = request.files['image']
img_bytes = file.read()
# Process image and get result
result_image = process_image(img_bytes)
# Return the processed image
return send_file(
result_image,
mimetype='image/jpeg',
as_attachment=True,
download_name='result.jpg'
)
if __name__ == '__main__':
app.run(debug=True)