-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
50 lines (36 loc) · 1.03 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Digital OCEAN FLASK SERVER RECEIVES IMAGE
from flask import Flask, request, jsonify
import classify
import base64
import firebase
import env
import json
# Instantiate Flask
app = Flask(__name__)
# health check
@app.route('/status')
def health_check():
return 'Running!'
# Performing image Recognition on Image, sent as bytes via POST payload
@app.route('/detect', methods=["POST"])
def detect():
imgBytes = request.data
imgdata = base64.b64decode(imgBytes)
with open("temp.png", 'wb') as f:
f.write(imgdata)
print("successfully receieved image")
# Pass image bytes to classifier\
imgPath= "testing.png"
result = classify.analyse(imgPath)
# Return results as neat JSON object, using
result = jsonify(result)
print(result.json)
response_data = result
print(response_data)
db = firebase.Firebase()
db.authenticate()
db.push(response_data)
print("Updated Firebase.")
return result
if __name__ == '__main__':
app.run(host='127.0.1.1', port=6969, debug=True)