From e2f20da264375de4bbfcba7b877d12f9e9228d2a Mon Sep 17 00:00:00 2001 From: 2004-19 <127276464+2004-19@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:30:41 +0530 Subject: [PATCH] Update application.py pie chart is added --- application.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/application.py b/application.py index e6e80fb..f73a563 100644 --- a/application.py +++ b/application.py @@ -1,6 +1,7 @@ import os import redis from datetime import datetime +from django.shortcuts import render from flask import Flask, flash, jsonify, redirect, render_template, request, session from flask_session import Session from flask_sqlalchemy import SQLAlchemy @@ -25,6 +26,20 @@ def after_request(response): response.headers["Pragma"] = "no-cache" return response +def history_view(request): + bought_stocks = ... # Logic to fetch bought stocks + sold_stocks = ... # Logic to fetch sold stocks + + bought_value = sum([stock.shares_bought for stock in bought_stocks]) + sold_value = sum([stock.shares_sold for stock in sold_stocks]) + + # Pass the data to the template + return render(request, 'your_template.html', { + 'bought_value': bought_value, + 'sold_value': sold_value, + }) + + # Custom filter application.jinja_env.filters["usd"] = usd @@ -535,4 +550,4 @@ def page_not_found(e): # Run Server # Run the following in the command line: python application.py if __name__ == '__main__': - application.run(host='0.0.0.0') \ No newline at end of file + application.run(host='0.0.0.0')