def bank(): if not session.has_key('user'): return redirect(url_for('login')) d=session['user'] soul=utils.get_soul(d) b=100-soul money=utils.get_money(d) if request.method=="GET": return render_template('bank.html', d=d, soul=soul, b=b, money=money) elif request.method=="POST": button=request.form["button"] if button=="Sell": try: amt_sell=int(request.form['selling']) if amt_sell>100 or amt_sell<0 or amt_sell>soul: return render_template("bank1.html",d=d,soul=soul,b=b,money=money) value=utils.sell_soul(d,amt_sell) return redirect(url_for("bank")) except Exception: return render_template("bank1.html",d=d,soul=soul,b=b,money=money) elif button=="Buy": try: amt_buy=int(request.form['buying']) if amt_buy>100 or amt_buy<0 or amt_buy>b: return render_template("bank1.html",d=d,soul=soul,b=b,money=money) value=utils.buy_soul(d,amt_buy) return redirect(url_for("bank")) except Exception: return render_template("bank1.html",d=d,soul=soul,b=b,money=money) return redirect(url_for("profile"))
def profile(): if not session.has_key('user'): return redirect(url_for('login')) elif request.method=="GET": d=session['user'] money=utils.get_money(d) stock=utils.get_stocks(d)[0] soul=utils.get_soul(d) gain=utils.get_stocks(d)[1] total=money+gain return render_template('profile.html',d=d,money=money,stock=stock,soul=soul,gain=gain,total=total) return redirect(url_for('profile'))