-
Notifications
You must be signed in to change notification settings - Fork 18
/
app.py
executable file
·30 lines (23 loc) · 661 Bytes
/
app.py
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
#!/usr/bin/python
from flask import Flask, jsonify, request, abort
from robotidentifier import RobotIdentifier
app = Flask(__name__)
i = 0
@app.route('/api/v1.0/image', methods=['POST'])
def classify_image():
global i
i += 1
print(request)
if not request.data:
print(request.data)
abort(400)
with open("image" + str(i) + ".jpg", "wb") as myfile:
myfile.write(request.data)
return jsonify({'return': identifier.find_and_classify("image" + str(i) + '.jpg')}), 201
@app.route('/')
def index():
return "Hello, World!"
if __name__ == '__main__':
global identifier
identifier = RobotIdentifier()
app.run(debug=True, host='0.0.0.0', port=80)