-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (21 loc) · 1010 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
#Importing the required dependencies
from flask import Flask, jsonify, request
from main import stock_data
# Initializing the app
app = Flask(__name__)
# Index endpoint (Explains how to use the url endpoint to get the stock values)
@app.route('/', methods = ['GET'])
def index():
Intro = "Welcome to Stock prediction app\nUse the company name and preriod to predict in following order: \n \
https://stockprediction-ml.herokuapp.com/[COMPANY NAME]/[DURATION] \n NOTE: if Company has two names you can use space in the url endpoint (Eg:General Motors)"
return Intro
# Main url endpoint to get the stock values
@app.route('/<compName>/<int:predict_period>', methods = ['GET'])
def stock_values(compName, predict_period):
compTicker = stock_data().get_stockSymbol(compName)
if compTicker:
return jsonify(stock_data().get_company_prediction(compTicker, predict_period))
else:
return "wrong company name"
if __name__ == "__main__":
app.run(debug = True)