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')