Trying to revive Numeri

This commit is contained in:
Jonathan Herrewijnen 2022-10-28 22:16:19 +02:00
parent 21faffb150
commit 440a73f828
20 changed files with 35 additions and 34 deletions

Binary file not shown.

Binary file not shown.

42
main.py
View File

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

BIN
plot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -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"<img src='data:image/png;base64,{data}'/>"
fig.savefig(f'static/plots/{uuid.uuid4()}.png', format="png")
# import pandas as pd

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
static/plots/plot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -11,8 +11,14 @@
</form>
<body>
<h1>{{title}}</h1>
<img src="/" alt="img_data" id="imgplot" />
<h1>{{ title }}</h1>
<section class="row">
{% for image in plots %}
<section class="col-md-4 col-sm-6" style="background-color: green;">
<a href="{{ url_for('static', filename='plots/' + image) }}">{{ image }}</a>
</section>
{% endfor %}
</section>
</body>
</html>