diff --git a/__pycache__/main.cpython-39.pyc b/__pycache__/main.cpython-39.pyc index 4109b36..53d5fea 100644 Binary files a/__pycache__/main.cpython-39.pyc and b/__pycache__/main.cpython-39.pyc differ diff --git a/__pycache__/plots.cpython-39.pyc b/__pycache__/plots.cpython-39.pyc index 44d9cdd..87e8156 100644 Binary files a/__pycache__/plots.cpython-39.pyc and b/__pycache__/plots.cpython-39.pyc differ diff --git a/main.py b/main.py index 9e3badf..c9fed10 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,36 @@ -# based on https://gist.github.com/rduplain/1641344 - -import random -from io import BytesIO -import base64 +# based on https://gist.github.com/rduplain/1641344 +import os from flask import Flask, make_response, request, render_template from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas -from matplotlib.figure import Figure import plots + +config = { + "DEBUG": True # run app in debug mode +} app = Flask(__name__) -@app.route('/') -def my_form(): - return render_template('index.html') +def figure(): + plots.plot() -@app.route('/', methods=['POST']) -def my_form_post(): - text = request.form['text'] - processed_text = text.upper() - return processed_text +@app.route('/', methods=["GET"]) +def root(): + title = "Project Numeri" + figure() + plots = os.listdir(os.path.join(app.static_folder, "plots")) + return render_template('index.html', title=title, plots=plots) + + +# @app.route('/', methods=['POST']) +# def my_form_post(): +# text = request.form['text'] +# processed_text = text.upper() +# return processed_text + +# def grades(): +# grades_list = pd.read_csv("*.csv") +# print(grades_list) -# @app.route('/') -# def plot_figure(): -# return plots.plot() if __name__ == '__main__': app.run(debug=True, port=5002) \ No newline at end of file diff --git a/plot.png b/plot.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/plot.png differ diff --git a/plots.py b/plots.py index 7664ecc..d24fe82 100644 --- a/plots.py +++ b/plots.py @@ -1,27 +1,14 @@ - -from io import BytesIO -from flask import Flask, render_template -# app = Flask("Project Numeri") -from flask import Flask, make_response, request from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure -import base64 +import uuid -# app = Flask(__name__) GRADE_LIST = "Cijfers-HerrewijnenJonathan.csv" -print(GRADE_LIST) def plot(): - # Generate the figure **without using pyplot**. fig = Figure() ax = fig.subplots() ax.plot([1, 2]) - # Save it to a temporary buffer. - buf = BytesIO() - fig.savefig(buf, format="png") - # Embed the result in the html output. - data = base64.b64encode(buf.getbuffer()).decode("ascii") - return f"" + fig.savefig(f'static/plots/{uuid.uuid4()}.png', format="png") # import pandas as pd diff --git a/static/plots/1a099ce5-1416-4c48-84b8-33470c4e923d.png b/static/plots/1a099ce5-1416-4c48-84b8-33470c4e923d.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/1a099ce5-1416-4c48-84b8-33470c4e923d.png differ diff --git a/static/plots/2927a53e-ae1f-41d8-915b-fac557637289.png b/static/plots/2927a53e-ae1f-41d8-915b-fac557637289.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/2927a53e-ae1f-41d8-915b-fac557637289.png differ diff --git a/static/plots/2b666d3c-41a9-4254-a0d7-f426b35a7e47.png b/static/plots/2b666d3c-41a9-4254-a0d7-f426b35a7e47.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/2b666d3c-41a9-4254-a0d7-f426b35a7e47.png differ diff --git a/static/plots/5ac5d6a2-1c2b-430e-9e73-393b584150e5.png b/static/plots/5ac5d6a2-1c2b-430e-9e73-393b584150e5.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/5ac5d6a2-1c2b-430e-9e73-393b584150e5.png differ diff --git a/static/plots/68330f3a-18f7-4335-a6a6-55df08910b6c.png b/static/plots/68330f3a-18f7-4335-a6a6-55df08910b6c.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/68330f3a-18f7-4335-a6a6-55df08910b6c.png differ diff --git a/static/plots/7810ed25-825b-4896-b34d-1c1e08523190.png b/static/plots/7810ed25-825b-4896-b34d-1c1e08523190.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/7810ed25-825b-4896-b34d-1c1e08523190.png differ diff --git a/static/plots/78d63720-9b69-45de-9017-fe8102b4170b.png b/static/plots/78d63720-9b69-45de-9017-fe8102b4170b.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/78d63720-9b69-45de-9017-fe8102b4170b.png differ diff --git a/static/plots/9cba9fdd-d0ae-4a75-8964-dfbad0d3f8e6.png b/static/plots/9cba9fdd-d0ae-4a75-8964-dfbad0d3f8e6.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/9cba9fdd-d0ae-4a75-8964-dfbad0d3f8e6.png differ diff --git a/static/plots/a6b7092f-3cd0-4636-b2d5-e60409b89074.png b/static/plots/a6b7092f-3cd0-4636-b2d5-e60409b89074.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/a6b7092f-3cd0-4636-b2d5-e60409b89074.png differ diff --git a/static/plots/be3fcb04-c835-48ef-949c-e2187ac21c1d.png b/static/plots/be3fcb04-c835-48ef-949c-e2187ac21c1d.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/be3fcb04-c835-48ef-949c-e2187ac21c1d.png differ diff --git a/static/plots/c9b40763-24f5-4839-a912-9c6dd64af257.png b/static/plots/c9b40763-24f5-4839-a912-9c6dd64af257.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/c9b40763-24f5-4839-a912-9c6dd64af257.png differ diff --git a/static/plots/cc5fcf0e-4b83-452f-93b5-c947ff313604.png b/static/plots/cc5fcf0e-4b83-452f-93b5-c947ff313604.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/cc5fcf0e-4b83-452f-93b5-c947ff313604.png differ diff --git a/static/plots/eb32f9ba-1974-449a-9cd8-da70e5a5d3c6.png b/static/plots/eb32f9ba-1974-449a-9cd8-da70e5a5d3c6.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/eb32f9ba-1974-449a-9cd8-da70e5a5d3c6.png differ diff --git a/static/plots/plot.png b/static/plots/plot.png new file mode 100644 index 0000000..51d512a Binary files /dev/null and b/static/plots/plot.png differ diff --git a/templates/index.html b/templates/index.html index e79fa63..6679b7a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,8 +11,14 @@ -

{{title}}

- img_data +

{{ title }}

+
+ {% for image in plots %} +
+ {{ image }} +
+ {% endfor %} +
\ No newline at end of file