forked from mjr390/Full_Stock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
166 lines (142 loc) · 5.67 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# import dependencies
from flask import Flask, render_template, jsonify
from flask_pymongo import PyMongo
import Create_mongo
# # to overrun heroku problems
from flask_cors import CORS, cross_origin
Create_mongo.populate()
# init the Flask
app = Flask(__name__)
# to overrun heroku problems
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/bitcoin_y_o_y'
# mongo = PyMongo(app)
#
# # Pass connection to the pymongo instance.
#
#
# # Connect to a database. Will create one if not already available.
# db = mongo.db
# create a route for scraping
# @app.route("/bit_y_o_y")
# ##### Give new name
# def BTC_vs_BTC():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/bitcoin_y_o_y'
# mongo = PyMongo(app)
# db = mongo.db
# btcY = db.bit_y_o_y.find_one()
# print(btcY)
# btcY_title = btcY["labels"]
# btcY_numbers = btcY["numbers"]
# btcY_dict = {"title":btcY_title, "numbers": btcY_numbers}
# print(btcY_title)
# # return appl_title
# return jsonify(btcY_dict)
# @app.route("/btc_v_all")
# def btc_v_all1():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/bitcoin_v_All'
# mongo = PyMongo(app)
# db = mongo.db
# btcA = db.bitcoin_v_All1.find_one()
# print(btcA)
# btcA_title = btcA["labels"]
# btcA_numbers = btcA["numbers"]
# btcA_Dates = btcA["Dates"]
# btcA_dict = {"title":btcA_title, "numbers":btcA_numbers, "Dates": btcA_Dates}
# return jsonify(btcA_dict)
# @app.route("/btc_Q")
# def btc_Q():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/bitcoin_Q'
# mongo = PyMongo(app)
# db = mongo.db
# btcQ = db.bitcoin_q.find_one()
# print(btcQ)
# btcQ_title = btcQ["labels"]
# btcQ_numbers = btcQ["numbers"]
# btcQ_dict = {"title":btcQ_title, "numbers":btcQ_numbers}
# return jsonify(btcQ_dict)
#
@app.route("/applY")
def applY():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/Apple_y_y' or "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
app.config["MONGO_URI"] = "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
mongo = PyMongo(app)
db = mongo.db
applY = db.apple_y_o_y.find_one()
print(applY)
applY_title = applY["labels"]
applY_numbers = applY["numbers"]
applY_Dates = applY["Dates"]
applY_nDates = applY["Dates_Normal"]
applY_Vol = applY["Volume"]
applY_Close = applY["Close"]
applY_Q = applY["Qs"]
applY_Ql = applY["Qmarks"]
applY_dict = {"title":applY_title, "Change":applY_numbers, "Dates": applY_Dates, "DatesN": applY_nDates, "Volume": applY_Vol, "Close": applY_Close,
"Qs": applY_Q, "Qmarks": applY_Ql}
return jsonify(applY_dict)
@app.route("/IBMY")
def ibmY():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/IBM_y_y' or "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
app.config["MONGO_URI"] = "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
mongo = PyMongo(app)
db = mongo.db
ibmY = db.ibm_y_o_y.find_one()
print(ibmY)
ibmY_title = ibmY["labels"]
ibmY_numbers = ibmY["numbers"]
imbY_Dates = ibmY["Dates"]
imbY_DatesN = ibmY["Dates_Normal"]
imbY_Vol = ibmY["Volume"]
imbY_Close = ibmY["Close"]
ibmY_Q = ibmY["Qs"]
ibmY_Ql = ibmY["Qmarks"]
ibmY_dict = {"title":ibmY_title, "Change":ibmY_numbers, "Dates":imbY_Dates, "DatesN": imbY_DatesN, "Volume": imbY_Vol, "Close":imbY_Close,
"Qs": ibmY_Q, "Qmarks": ibmY_Ql}
return jsonify(ibmY_dict)
@app.route("/IntelY")
def intelY():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/Intel_y_y' or "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
app.config["MONGO_URI"] = "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
mongo = PyMongo(app)
db = mongo.db
intelY = db.intel_y_o_y.find_one()
print(intelY)
intelY_title = intelY["labels"]
intelY_numbers = intelY["numbers"]
intelY_Dates = intelY["Dates"]
intelY_DatesN = intelY["Dates_Normal"]
intelY_Vol = intelY["Volume"]
intelY_Close = intelY["Close"]
intelY_Q = intelY["Qs"]
intelY_Ql = intelY["Qmarks"]
intelY_dict = {"title":intelY_title, "Change":intelY_numbers, "Dates": intelY_Dates, "DatesN": intelY_DatesN, "Volume": intelY_Vol,
"Close":intelY_Close, "Qs": intelY_Q, "Qmarks": intelY_Ql}
return jsonify(intelY_dict)
@app.route("/MSFTY")
def msftY():
# app.config["MONGO_URI"] = 'mongodb://localhost:27017/MSFT_y_y' or "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
app.config["MONGO_URI"] = "mongodb://heroku_8nx1c4b9:[email protected]:17623/heroku_8nx1c4b9"
mongo = PyMongo(app)
db = mongo.db
msftlY = db.msft_y_o_y.find_one()
print(msftlY)
msftlY_title = msftlY["labels"]
msftlY_numbers = msftlY["numbers"]
msftlY_Date = msftlY["Dates"]
msftlYY_DatesN = msftlY["Dates_Normal"]
msftlY_Vol = msftlY["Volume"]
msftlYY_Close = msftlY["Close"]
msftlYY_Q = msftlY["Qs"]
msftlY_Ql = msftlY["Qmarks"]
msftlY_dict = {"title":msftlY_title, "Change":msftlY_numbers, "Dates": msftlY_Date, "DatesN": msftlYY_DatesN, "Volume": msftlY_Vol,
"Close":msftlYY_Close, "Qs": msftlYY_Q, "Qmarks": msftlY_Ql}
return jsonify(msftlY_dict)
# create a index route
@app.route('/')
def index():
# Return the template with the teams list passed in
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)