I'm currently in the midst of migrating my CLI application to a flask dashboard GUI. One of the main function is exporting the required data to a .csv file which I have made a dedicated folder for.
This is what I've came up with for the flask function:
@app.route('/third-static')
def third_static():
csv_data = []
# Read all .csv files in the attendance_folder
for filename in os.listdir(attendance_folder):
if filename.endswith('.csv'):
filepath = os.path.join(attendance_folder, filename)
with open(filepath, 'r', newline='', encoding='utf-8') as csvfile:
csvreader = csv.reader(csvfile)
data = list(csvreader)
csv_data.append({
'filename': filename,
'data': data
})
return render_template('third-static.html', csv_data=csv_data)
I've been struggling to implement this into my html page. If there are any references or solutions to this I'd really appreciate it.