fixed indentation issues with saveportfoliosettings
This commit is contained in:
parent
d0fbaa74a4
commit
6cd628b0cf
47
server.py
47
server.py
@ -701,35 +701,36 @@ def savePortfolioSettings():
|
|||||||
data= request.data.decode('utf-8')
|
data= request.data.decode('utf-8')
|
||||||
settings = json.loads(data)
|
settings = json.loads(data)
|
||||||
|
|
||||||
#THIS IS TO CREATE PORTFOLIO JSON FILE IF IT DOESN'T EXIST
|
#THIS IS TO CREATE PORTFOLIO JSON FILE IF IT DOESN'T EXIST
|
||||||
initialize_json = '{"symbols":{}}'
|
initialize_json = '{"symbols":{}}'
|
||||||
if 'portfolio_settings.json' not in os.listdir('csv/'):
|
if 'portfolio_settings.json' not in os.listdir('csv/'):
|
||||||
with open('csv/portfolio_settings.json', 'w') as f:
|
with open('csv/portfolio_settings.json', 'w') as f:
|
||||||
f.write(initialize_json)
|
f.write(initialize_json)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open('csv/portfolio_settings.json')
|
f = open('csv/portfolio_settings.json')
|
||||||
portfolio = json.load(f)
|
portfolio = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
shares1 = settings['shares']
|
shares1 = settings['shares']
|
||||||
cost1 = settings['cost']
|
cost1 = settings['cost']
|
||||||
symbol1 = settings['symbol']
|
symbol1 = settings['symbol']
|
||||||
|
|
||||||
days1 = settings['days']
|
days1 = settings['days']
|
||||||
day_start = datetime.strptime(days1, "%Y-%m-%d")
|
day_start = datetime.strptime(days1, "%Y-%m-%d")
|
||||||
day_today = datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%d"), "%Y-%m-%d")
|
day_today = datetime.strptime(datetime.now(pytz.utc).strftime("%Y-%m-%d"), "%Y-%m-%d")
|
||||||
days1 = str((day_today - day_start).days)
|
days1 = str((day_today - day_start).days)
|
||||||
|
|
||||||
portfolio['symbols'][symbol1] = {'shares':shares1, 'day':days1, 'cost':cost1}
|
portfolio['symbols'][symbol1] = {'shares':shares1, 'day':days1, 'cost':cost1}
|
||||||
|
|
||||||
f = open("csv/portfolio_settings.json", 'w+')
|
f = open("csv/portfolio_settings.json", 'w+')
|
||||||
json.dump(portfolio, f)
|
json.dump(portfolio, f)
|
||||||
f.close()
|
f.close()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
return index()
|
||||||
|
|
||||||
return index()
|
|
||||||
|
|
||||||
@app.route("/screensaver", methods = ['PUT', 'POST'])
|
@app.route("/screensaver", methods = ['PUT', 'POST'])
|
||||||
def screensaver():
|
def screensaver():
|
||||||
|
Loading…
Reference in New Issue
Block a user