Bug in keeping checked/unchecked in check.
This commit is contained in:
parent
440a73f828
commit
7f17e72d61
Binary file not shown.
Binary file not shown.
51
main.py
51
main.py
@ -3,6 +3,7 @@ import os
|
|||||||
from flask import Flask, make_response, request, render_template
|
from flask import Flask, make_response, request, render_template
|
||||||
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
||||||
import plots
|
import plots
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"DEBUG": True # run app in debug mode
|
"DEBUG": True # run app in debug mode
|
||||||
@ -10,27 +11,49 @@ config = {
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
params = []
|
||||||
|
|
||||||
|
|
||||||
|
def grade_files():
|
||||||
|
grade_files = {}
|
||||||
|
for file in os.listdir('./'):
|
||||||
|
if file.endswith(".csv"):
|
||||||
|
grade_files[file] = {}
|
||||||
|
grade_file = pd.read_csv(file, skiprows=2, sep=';')
|
||||||
|
for i in grade_file:
|
||||||
|
grade_files[file][i] = 'checked'
|
||||||
|
break # Could add exam fle at some point here as well
|
||||||
|
return grade_files
|
||||||
|
|
||||||
|
|
||||||
def figure():
|
def figure():
|
||||||
plots.plot()
|
plots.plot()
|
||||||
|
|
||||||
@app.route('/', methods=["GET"])
|
|
||||||
def root():
|
def value_to_list(given_list, old_value, new_value):
|
||||||
|
given_list = list(map(lambda x: x[1].replace(old_value, new_value), [j for j in given_list]))
|
||||||
|
return given_list
|
||||||
|
|
||||||
|
|
||||||
|
def initialize():
|
||||||
title = "Project Numeri"
|
title = "Project Numeri"
|
||||||
figure()
|
|
||||||
plots = os.listdir(os.path.join(app.static_folder, "plots"))
|
plots = os.listdir(os.path.join(app.static_folder, "plots"))
|
||||||
return render_template('index.html', title=title, plots=plots)
|
return title, plots, grade_files()
|
||||||
|
|
||||||
|
|
||||||
# @app.route('/', methods=['POST'])
|
# Renders template. All below is constantly executed by Flask
|
||||||
# def my_form_post():
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
# text = request.form['text']
|
def root():
|
||||||
# processed_text = text.upper()
|
title, plots, grade_files = params
|
||||||
# return processed_text
|
if request.method == 'POST':
|
||||||
|
form = request.form
|
||||||
# def grades():
|
for filename in grade_files:
|
||||||
# grades_list = pd.read_csv("*.csv")
|
grade_files_unchecked = grade_files[filename].keys() - form.keys()
|
||||||
# print(grades_list)
|
for column_name in grade_files_unchecked:
|
||||||
|
grade_files[filename][column_name] = "unchecked"
|
||||||
|
return render_template('index.html', title=title, plots=plots, grade_files=grade_files)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, port=5002)
|
params = initialize()
|
||||||
|
app.run(debug=True, port=5003)
|
BIN
static/plots/9e7c2c5f-1011-43fc-827d-3e0c4120a1b2.png
Normal file
BIN
static/plots/9e7c2c5f-1011-43fc-827d-3e0c4120a1b2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
static/plots/e159fb01-466c-4582-afe5-a9b7c963c1b9.png
Normal file
BIN
static/plots/e159fb01-466c-4582-afe5-a9b7c963c1b9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
static/plots/f60d0f3e-9e8b-4672-b43c-07e3be7da97d.png
Normal file
BIN
static/plots/f60d0f3e-9e8b-4672-b43c-07e3be7da97d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -5,17 +5,26 @@
|
|||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<script>"jquery-3.6.0.min.js"</script>
|
<script>"jquery-3.6.0.min.js"</script>
|
||||||
</head>
|
</head>
|
||||||
<form method="POST">
|
|
||||||
<input name="text">
|
|
||||||
<input type="submit">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
|
{% for grade_file in grade_files %}
|
||||||
|
<h2>
|
||||||
|
{{ grade_file }}
|
||||||
|
<form method="post">
|
||||||
|
{% for key, value in grade_files[grade_file].items() %}
|
||||||
|
<!-- /*<input type="submit" name={{ index }} value={{ index }}>*/ -->
|
||||||
|
<input type="checkbox" name={{ key }} value={{ key }} {{ value }}>
|
||||||
|
<label for={{ key0 }}>{{ key }}</label>
|
||||||
|
{% endfor %}
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
|
</h2>
|
||||||
|
{% endfor %}
|
||||||
<section class="row">
|
<section class="row">
|
||||||
{% for image in plots %}
|
{% for image in plots %}
|
||||||
<section class="col-md-4 col-sm-6" style="background-color: green;">
|
<section class="col-md-4 col-sm-6">
|
||||||
<a href="{{ url_for('static', filename='plots/' + image) }}">{{ image }}</a>
|
<img src="{{ url_for('static', filename='plots/' + image) }}" alt=img/>
|
||||||
|
<h3>{{ image }}</h3>
|
||||||
</section>
|
</section>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user