-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (26 loc) · 833 Bytes
/
main.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
from flask import Flask, render_template, request, jsonify
from predict import fruit
# flask utils
from flask_cors import CORS, cross_origin
from utils.utils import decodeImage
import os
os.putenv('LANG', 'en_US.UTF-8')
os.putenv('LC_ALL', 'en_US.UTF-8')
# define a flask app
app = Flask(__name__)
class ClientApp:
def __init__(self):
self.filename = "logo.png"
self.classifier = fruit(self.filename)
@app.route('/', methods=['GET'])
def home():
return render_template("index.html")
@app.route('/predict', methods=['POST'])
def predict():
image = request.json['image']
decodeImage(image, clApp.filename)
result = clApp.classifier.fruitCheck()
return jsonify(result)
if __name__== '__main__':
clApp = ClientApp()
app.run(port=3000, debug=True)