-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
38 lines (28 loc) · 869 Bytes
/
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
import json
from flask import Blueprint, Flask, request, Response
from flask_cors import CORS
from build_model import Model
from utils import get_coords_by_address
ml = Blueprint('ml', __name__)
CORS(ml)
model = Model()
@ml.route('/predict', methods=['GET'])
def predict():
if request.method != 'GET':
return Response(
json.dumps({'status': 'error', 'message': 'Method not allowed.'}),
status=405
)
data = request.args
address = data['address']
volume = float(data['volume'])
date = data['date']
dates = model.get_time(date, address, volume)
return Response(
json.dumps({'status': 'ok', 'data': dates}),
status=200
)
if __name__ == '__main__':
app = Flask(__name__)
app.register_blueprint(ml, url_prefix='')
app.run(host='0.0.0.0', port=8080, debug=True)