-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (20 loc) · 756 Bytes
/
app.py
File metadata and controls
30 lines (20 loc) · 756 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
import os
from flask import Flask, request, send_from_directory, json, jsonify
from doggyML.dog_classify import classify_image
from waitress import serve
def create_app(test_config=None):
app = Flask(__name__)
@app.route("/", methods=['POST'])
def index():
if not 'image' in request.files:
content = {'error': 'please send an image'}
return json.jsonify(content), 400
file = request.files['image']
file.save(file.filename)
breed = classify_image(file.filename)
return breed
@app.route('/static/<path:path>', methods=['GET'])
def send_static(path):
return send_from_directory('static', path)
return app
serve(create_app(), listen='*:8080')