-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
54 lines (38 loc) · 1.13 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
51
52
53
54
# app.py
from flask import Flask, request, jsonify, send_from_directory
from time import sleep
import multiprocessing as mp
import model_manager as mm
import json
app = Flask(__name__)
@app.route('/')
def send_home():
return(send_from_directory('html', 'setup.html'))
@app.route('/app/<path:path>')
def send_js(path):
return send_from_directory('html', path)
@app.route('/start-model', methods=['POST'])
def start():
content = request.get_json()
print(content)
result = mm.start_model(content)
return(result)
@app.route('/status', methods=['POST'])
def check():
data = request.get_json()
key = data["key"]
result = mm.get_model_status(key)
return(result)
@app.route('/ping', methods=['GET'])
def ping():
return(mm.ping_model())
@app.route('/stop-model', methods=['POST'])
def stop():
print("stop!")
@app.route('/get-sample-output', methods=["GET"])
def get_sample_output():
with open('data/output.json') as json_file:
data = json.load(json_file)
return(jsonify(data))
if __name__ == '__main__':
app.run(threaded=False, processes=1) # app.run(threaded=True, port=5000)