2024-12-16

This commit is contained in:
2024-12-16 08:25:39 -06:00
parent 35677f7e95
commit f65cf3c1ed
7 changed files with 1961 additions and 174 deletions

View File

@@ -4,7 +4,7 @@ import os
import caldav
import datetime
from icalendar import cal, Event
from flask import render_template, url_for, send_file, send_from_directory
from flask import render_template, url_for, send_file, send_from_directory, request
from .models import Event
import requests
import imgkit
@@ -88,27 +88,27 @@ def dashboard():
days.append((single_date, days_events))
# breakpoint()
pass
extra_debug = request.args.get('extra', '')
# r = "<br>".join([event.vobject_instance.vevent.summary.value for event in events_fetched if event.vobject_instance.vevent.dtstart.value < datetime.now()])
return render_template("dashboard_static.html",
return render_template("dashboard.html",
days=days,
today=today,
weather=weather()
weather=weather(),
extra_debug=extra_debug
)
@app.route('/image')
def dashboard_image():
extension = "png"
page = dashboard()
out_file = os.path.join(os.path.dirname(__file__),
'static', "out.bmp"
'static', f'out.{extension}'
)
s = imgkit.from_string(
page,
out_file,
options={
'width':600,
'height':800,
"disable-smart-width": "",
@@ -117,12 +117,9 @@ def dashboard_image():
'static',
)
},
css=os.path.join(os.path.dirname(__file__),
'static',
'style.css'
)
# css=os.path.join(os.path.dirname(__file__),'static','style.css')
)
image_file = Image.open(out_file) # open colour image
image_file = ImageOps.grayscale(image_file)
image_file.save(out_file, 'BMP')
return send_from_directory(directory = 'static', path='out.bmp', as_attachment=False, attachment_filename='out.bmp')
return send_from_directory(directory = 'static', path=f'out.{extension}', as_attachment=False, attachment_filename=f'out.{extension}')