-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (20 loc) · 649 Bytes
/
app.py
File metadata and controls
33 lines (20 loc) · 649 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
31
32
33
from flask import Flask, request, jsonify
from flask_cors import CORS, cross_origin
from forecast import predict
app = Flask(__name__)
CORS(app)
@app.route('/predict', methods=['POST'], strict_slashes=False)
@cross_origin()
def forecast():
# get the ticker from the payl
ticker = request.json['ticker'].upper()
result = predict(ticker)
# throw error 400 if no data
if result == 'No data':
return jsonify({"errorType": 406, "message": result}), 406
return jsonify({"result": result})
@app.route('/')
def homepage():
return jsonify({"result":"connected"})
if __name__ == '__main__':
app.run()