Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
Latest commit
61 lines (47 loc) · 1.75 KB
/
Copy pathapp.py
File metadata and controls
61 lines (47 loc) · 1.75 KB
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
51
52
53
54
55
56
57
58
59
60
61
fromflaskimportFlask, request, render_template, abort
frommodulesimportface, objectasobj, utility
frommodelsimportresult
fromwaitressimportserve
defcreate_app():
# create and configure the app
app=Flask("got it", instance_relative_config=True)
# configure max size of payload content
app.config['MAX_CONTENT_LENGTH'] =15*1024*1024
# app routes here
@app.route("/", methods=["GET"])
defindex():
returnrender_template('index.html')
@app.route("/api/face/detect", methods=["POST"])
defface_detection():
returnface.extract_face(request.json)
@app.route("/api/face/match", methods=["POST"])
defface_recognition():
returnface.recognition(request.json)
@app.route("/api/object/detect", methods=["POST"])
defobject_detection():
returnobj.detect(request.json)
@app.route("/api/object/match", methods=["POST"])
defobject_recognition():
returnobj.recognition(request.json)
@app.errorhandler(400)
defbad_request(error):
returnresult.failed(None, str(error), 400)
@app.errorhandler(401)
defbad_request(error):
returnresult.failed(None, str(error), 401)
@app.errorhandler(404)
defnot_found(error):
returnresult.failed(None, str(error), 404)
@app.errorhandler(405)
defmethod_not_allowed(error):
returnresult.failed(None, str(error), 405)
@app.errorhandler(413)
defrequest_entity_too_large(error):
returnresult.failed(None, str(error), 413)
returnapp
if__name__=="__main__":
app=create_app()
# to start server run this command
# windows: SET FLASK_APP=app.py & flask run
# linux: export FLASK_APP=app.py & flask run
serve(app)