svg + responsive

This commit is contained in:
2026-08-09 11:13:28 +02:00
parent 0f344a1ab7
commit 7f53bc6488
4 changed files with 62 additions and 36 deletions
+19 -24
View File
@@ -9,6 +9,8 @@ from pprint import pprint
app = Flask(__name__)
compiler = typst.Compiler()
@app.route("/")
def index():
cours_base = [
@@ -211,32 +213,25 @@ def index():
def favicon():
return send_file("favicon.ico")
@app.route('/edt.pdf', methods=["GET", "POST"])
@app.route('/edt.pdf', methods=["POST"])
def generate_pdf():
if request.method != "POST":
data = {
"cours": [
{"day": 0, "start": "08:15", "end": "10:xx", "name": "Algèbre (CM)", "prof": "Jean-Benoît Bost", "room": "OA1", "color": "#ff80b3"},
{"day": 0, "start": "10:30", "end": "13:00", "name": "Algèbre (TD)", "prof": "x", "room": "OA1", "color": "#ff80b3"},
{"day": 3, "start": "14:00", "end": "16:00", "name": "Algèbre (CM)", "prof": "Jean-Benoît Bost", "room": "OA1", "color": "#ff80b3"},
{"day": 3, "start": "16:15", "end": "18:45", "name": "Algèbre (TD)", "prof": "x", "room": "OA1", "color": "#ff80b3"},
{"day": 0, "start": "14:00", "end": "16:00", "name": "Analyse (CM)", "prof": "Blanche Buet", "room": "OA1", "color": "#80ffcc"},
{"day": 0, "start": "16:15", "end": "18:45", "name": "Analyse (TD)", "prof": "x", "room": "OA1", "color": "#80ffcc"},
{"day": 2, "start": "08:15", "end": "10:15", "name": "Analyse (CM)", "prof": "Blanche Buet", "room": "OA1", "color": "#80ffcc"},
{"day": 2, "start": "10:30", "end": "13:00", "name": "Analyse (TD)", "prof": "x", "room": "OA1", "color": "#80ffcc"},
{"day": 1, "start": "14:00", "end": "16:00", "name": "Cryptographie (CM)", "prof": "Stéphane Fischler","room": "OA1", "color": "#e6b3ff"},
{"day": 4, "start": "10:30", "end": "12:30", "name": "Cryptographie (TP)", "prof": "Chimène Fischler", "room": "OA1", "color": "#e6b3ff"},
]
}
print(data)
else:
data = json.loads(request.data)
pprint(data)
data = json.loads(request.data)
pprint(data)
sys_inputs = {"data": json.dumps(data)}
pdf_file = BytesIO(typst.compile(input="templates/edt.typ", sys_inputs=sys_inputs))
pdf_file = BytesIO(compiler.compile(input="templates/edt.typ", sys_inputs=sys_inputs))
return send_file(pdf_file, download_name="edt.pdf")
@app.route('/edt.svg', methods=["POST"])
def generate_svg():
data = json.loads(request.data)
pprint(data)
sys_inputs = {"data": json.dumps(data)}
pdf_file = BytesIO(compiler.compile(input="templates/edt.typ", sys_inputs=sys_inputs, format="svg"))
return send_file(pdf_file, download_name="edt.svg")
return send_file(pdf_file, download_name="edt.pdf")