diff --git a/app.py b/app.py index 1ad5c28..8650222 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,6 @@ import requests, os import plotly.graph_objects as go +import plotly.express as px from flask import Flask, render_template, jsonify, make_response from weasyprint import HTML @@ -8,12 +9,14 @@ app = Flask(__name__) @app.route('/report') def report(): # Create Plotly graph - fig = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[10, 20, 30], mode='lines')]) + #fig = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[10, 20, 30], mode='lines')]) + df = px.data.stocks() + fig = px.line(df, x='date', y=['AAPL', 'GOOG']) # Save the graph as an image image_path = os.path.join('static', 'graph.svg') - fig.write_image(image_path) - return render_template('report.html', graph_image=image_path) + + return render_template('report.html', graph_image=image_path, table_data = df) @app.route('/') def home(): diff --git a/static/graph.svg b/static/graph.svg index 6114cf6..1a9d5e8 100644 --- a/static/graph.svg +++ b/static/graph.svg @@ -1 +1 @@ -11.522.531015202530 \ No newline at end of file +Jan 2018Jul 2018Jan 2019Jul 20190.911.11.21.31.41.51.61.7variableAAPLGOOGdatevalue \ No newline at end of file diff --git a/templates/report.html b/templates/report.html index aec79fc..a89f5f5 100644 --- a/templates/report.html +++ b/templates/report.html @@ -8,15 +8,17 @@ - - + + + - {% for row in table_data %} + {% for index,row in table_data.iterrows() %} - - + + + {% endfor %}
Header 1Header 2DateGoogle Stock PriceApple Stock Price
{{ row[0] }}{{ row[1] }}{{ row['date'] }}{{ row['GOOG'] }}{{ row['AAPL'] }}