fetch crypto and stock portfolio values and send back to app.js

This commit is contained in:
Justin 2023-07-11 17:05:41 +08:00 committed by GitHub
parent a5e30dfc1c
commit 73a3220fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1515,6 +1515,41 @@ def setTop20or10():
return index()
@app.route("/fetchStockPortfolio", methods=["POST"])
def fetchStockPortfolio():
value = request.data.decode('utf-8')
value2 = json.loads(value)
try:
with open("csv/portfolio_settings.json") as f:
data = json.load(f)
except:
data = {"symbols": {}}
try:
stock_pos_info = data['symbols'][value2]
except:
stock_pos_info = {}
return (stock_pos_info)
@app.route("/fetchCryptoPortfolio", methods=["POST"])
def fetchCryptoPortfolio():
value = request.data.decode('utf-8')
value2 = json.loads(value)
try:
with open("csv/portfolio_crypto_settings.json") as f:
data = json.load(f)
except:
data = {"symbols": {}}
try:
crypto_pos_info = data['symbols'][value2]
except:
crypto_pos_info = {}
return (crypto_pos_info)
@app.route("/fetchCustomMsg", methods=["POST"])
def fetch_custom_msg():
value = request.data.decode('utf-8')