-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·47 lines (37 loc) · 1.29 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
from flask import Flask, render_template, url_for
from flask_weasyprint import HTML, CSS, render_pdf
app = Flask(__name__)
@app.route("/")
def template_main():
return render_template('main.html', temps=temp_table(), pa=pa_table())
@app.route("/verso")
def template_verso():
return render_template('main-verso.html')
@app.route("/verso.pdf")
def pdf_verso():
css = CSS(string='@page { size: 450mm 620mm; margin: 0.5cm; }')
a3css = CSS(string='@page { size: A3; margin: 0.5cm; }')
#return render_template('main-verso.html')
html = render_template('main-verso.html')
return render_pdf(HTML(string=html), stylesheets=[css])
@app.route("/rea.pdf")
def pdf_main():
css=CSS(string='@page { size: 450mm 620mm; margin: 0.1cm; }')
a3css = CSS(string='@page { size: A3; margin: 0.3cm; }')
html = render_template('main.html', temps=temp_table(), pa=pa_table())
return render_pdf(HTML(string=html), stylesheets=[css])
def temp_table():
temps = []
for i in range(0,24):
temp = i+14
if temp < 24:
temps.append(temp)
else:
temps.append(temp-24)
return temps
def pa_table():
pa = [30, 24, 20, 15, 10, 5, 0]
return pa
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0", port=8000)