From b701824e5a0cb9bcf8e641a1fb6f487daf0f5e21 Mon Sep 17 00:00:00 2001 From: Pranika Kalimuthu <123928079+PranikaBaby@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:46 +0530 Subject: [PATCH] feat: add stock portfolio pie chart visualization --- application.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/application.py b/application.py index e6e80fb..085e435 100644 --- a/application.py +++ b/application.py @@ -19,11 +19,19 @@ # Ensure responses aren't cached @application.after_request -def after_request(response): - response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" - response.headers["Expires"] = 0 - 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 +543,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')