Initial commit
This commit is contained in:
@@ -0,0 +1,242 @@
|
||||
from flask import Flask
|
||||
from flask import render_template, send_file, request, redirect, url_for
|
||||
import typst
|
||||
import json
|
||||
from io import BytesIO
|
||||
import random
|
||||
|
||||
from pprint import pprint
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
cours_base = [
|
||||
# ALGEBRE
|
||||
{
|
||||
"ue": "algebre",
|
||||
"name": "Algèbre",
|
||||
"color": "#ff80b3",
|
||||
"cm": [
|
||||
{
|
||||
"prof": "Jean-Benoît Bost",
|
||||
"day": 0, "start": "08:15", "end": "10:15", "room": "Amphi Yoccoz",
|
||||
},
|
||||
{
|
||||
"prof": "Jean-Benoît Bost",
|
||||
"day": 3, "start": "14:00", "end": "16:00", "room": "Amphi Yoccoz",
|
||||
},
|
||||
],
|
||||
"td": [
|
||||
{
|
||||
"group": 1,
|
||||
"prof": "Kévin Destagnol",
|
||||
"slots": [
|
||||
{"day": 0, "start": "10:30", "end": "13:00", "room": "0A2"},
|
||||
{"day": 3, "start": "16:15", "end": "18:45", "room": "0A2"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"group": 2,
|
||||
"prof": "Pierre Lorenzon",
|
||||
"slots": [
|
||||
{"day": 0, "start": "10:30", "end": "13:00", "room": "0A7"},
|
||||
{"day": 3, "start": "16:15", "end": "18:45", "room": "0E1"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
# ANALYSE
|
||||
{
|
||||
"ue": "analyse",
|
||||
"name": "Analyse",
|
||||
"color": "#80ffcc",
|
||||
"cm": [
|
||||
{
|
||||
"prof": "Blanche Buet",
|
||||
"day": 0, "start": "14:00", "end": "16:00", "room": "OA2",
|
||||
},
|
||||
{
|
||||
"prof": "Blanche Buet",
|
||||
"day": 2, "start": "08:15", "end": "10:15", "room": "OA1",
|
||||
},
|
||||
],
|
||||
"td": [
|
||||
{
|
||||
"group": 1,
|
||||
"prof": "Frédéric Valet",
|
||||
"slots": [
|
||||
{"day": 0, "start": "16:15", "end": "18:45", "room": "0A2"},
|
||||
{"day": 2, "start": "10:30", "end": "13:00", "room": "0A1"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"group": 2,
|
||||
"prof": "Sebastian Bechtel",
|
||||
"slots": [
|
||||
{"day": 0, "start": "16:15", "end": "18:45", "room": "0A7"},
|
||||
{"day": 2, "start": "10:30", "end": "13:00", "room": "0D1"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
# PROBAS
|
||||
{
|
||||
"ue": "probas",
|
||||
"name": "Probabilités",
|
||||
"color": "#ffcc99",
|
||||
"cm": [
|
||||
{
|
||||
"prof": "Pierre-Loïc Méliot",
|
||||
"day": 1, "start": "08:15", "end": "10:15", "room": "Amphi Yoccoz",
|
||||
},
|
||||
{
|
||||
"prof": "Pierre-Loïc Méliot",
|
||||
"day": 3, "start": "08:15", "end": "10:15", "room": "Amphi Yoccoz",
|
||||
},
|
||||
],
|
||||
"td": [
|
||||
{
|
||||
"group": 1,
|
||||
"prof": "Sophie Lemaire",
|
||||
"slots": [
|
||||
{"day": 1, "start": "10:30", "end": "13:00", "room": "0D1"},
|
||||
{"day": 3, "start": "10:30", "end": "13:00", "room": "0E1"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"group": 2,
|
||||
"prof": "A. Legrand",
|
||||
"slots": [
|
||||
{"day": 1, "start": "10:30", "end": "13:00", "room": "Amphi Yoccoz"},
|
||||
{"day": 3, "start": "10:30", "end": "13:00", "room": "0A2"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
cours_autres = [
|
||||
{
|
||||
"ue": "crypto",
|
||||
"name": "Cryptographie",
|
||||
"color": "#e6b3ff",
|
||||
"atoms": [
|
||||
{
|
||||
"label": "CM",
|
||||
"prof": "Stéphane Fischler",
|
||||
"day": 1,
|
||||
"start": "14:00",
|
||||
"end": "16:00",
|
||||
"room": "0A2",
|
||||
},
|
||||
{
|
||||
"label": "TP",
|
||||
"prof": "Chimène Fischler",
|
||||
"day": 4,
|
||||
"start": "10:30",
|
||||
"end": "12:30",
|
||||
"room": "0E10",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"ue": "geo_alea",
|
||||
"name": "Géométrie aléatoire",
|
||||
"color": "#ccb3ff",
|
||||
"atoms": [
|
||||
{
|
||||
"label": "CM",
|
||||
"prof": "N. Curien",
|
||||
"day": 1,
|
||||
"start": "16:15",
|
||||
"end": "18:15",
|
||||
"room": "1A7",
|
||||
},
|
||||
{
|
||||
"label": "TP",
|
||||
"prof": "A. Legrand",
|
||||
"day": 4,
|
||||
"start": "08:15",
|
||||
"end": "10:15",
|
||||
"room": "0D10",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"ue": "edp_num",
|
||||
"name": "EDP numériques",
|
||||
"color": "#ccebff",
|
||||
"atoms": [
|
||||
{
|
||||
"label": "CM",
|
||||
"prof": "B. Maury",
|
||||
"day": 1,
|
||||
"start": "16:15",
|
||||
"end": "18:15",
|
||||
"room": "0A5",
|
||||
},
|
||||
{
|
||||
"label": "TP",
|
||||
"prof": "B. Graille",
|
||||
"day": 4,
|
||||
"start": "08:15",
|
||||
"end": "10:15",
|
||||
"room": "0E10",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"ue": "topalg",
|
||||
"name": "Topologie algébrisée",
|
||||
"color": "#a366ff",
|
||||
"atoms": [
|
||||
{
|
||||
"label": "CI",
|
||||
"prof": "Patrick Massot",
|
||||
"day": 2,
|
||||
"start": "14:00",
|
||||
"end": "18:15",
|
||||
"room": "0A1",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
return render_template('index.html', cours_base=cours_base, cours_autres=cours_autres)
|
||||
|
||||
|
||||
@app.route("/favicon.ico")
|
||||
def favicon():
|
||||
return send_file("favicon.ico")
|
||||
|
||||
@app.route('/edt.pdf', methods=["GET", "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)
|
||||
|
||||
sys_inputs = {"data": json.dumps(data)}
|
||||
|
||||
pdf_file = BytesIO(typst.compile(input="templates/edt.typ", sys_inputs=sys_inputs))
|
||||
|
||||
return send_file(pdf_file, download_name="edt.pdf")
|
||||
Reference in New Issue
Block a user