-
Notifications
You must be signed in to change notification settings - Fork 0
/
html_template.py
266 lines (247 loc) · 8.24 KB
/
html_template.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import arrow
from weather_forecast import Weather
from wave_forecast import StormGlass
class Email_Content:
def write():
weather_forecast = Weather.report()
wave_forecast = StormGlass.data()
dt_now = arrow.now(tz='Europe/London')
html_str1 = """<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Verdana, sans-serif;
font-size: 12px;
line-height: 1.5;
color: #1f5070;
text-align: center;
margin: 10;
padding: 0;
}
h1 {
font-size: 20px;
font-weight: bold;
text-align: center;
margin-top: 20px;
margin-bottom: 10px;
}
h2 {
font-size: 20px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 10px;
}
table {
border-collapse: collapse;
width: 100%;
max-width: 600px;
margin: auto auto;
}
td {
color: #030303;
border: 1px solid #297fb9;
padding: 6px;
text-align: center;
vertical-align: left;
font-weight: bold;
color: #1f5070;
margin: 3px 0;
}
th {
background-color: #2980B9;
color: rgb(255, 255, 255);
font-weight: bold;
text-align: center;
padding: 8px 8px;
border-top: 1px solid #2980B9;
border-bottom: 1px solid #ffffff;
border-left: 1px solid #2980B9;
}
th:first-child {
border-left: none;
}
th:last-child {
border-right: none;
}
img {
display: block;
max-width: 100%;
height: auto;
margin: 0 auto;
}
p {
font-weight: bold;
color: #1f5070;
margin: 3px 0;
}
</style>
</head>"""
html_str2 = """
<body>
<h1>Canford Cliffs</h1>
<h1>Weather</h1>
<table>
<tr>
<th>Today</th>
<th>{day2}</th>
<th>{day3}</th>
<th>{day4}</th>
<th>{day5}</th>
</tr>
<tr>
<td><img src="https://openweathermap.org/img/wn/{icon1}.png" alt="image" width=auto height=auto></td>
<td><img src="https://openweathermap.org/img/wn/{icon2}.png" alt="image" width=auto height=auto></td>
<td><img src="https://openweathermap.org/img/wn/{icon3}.png" alt="image" width=auto height=auto></td>
<td><img src="https://openweathermap.org/img/wn/{icon4}.png" alt="image" width=auto height=auto></td>
<td><img src="https://openweathermap.org/img/wn/{icon5}.png" alt="image" width=auto height=auto></td>
</tr>
</table>
<br>
<table>
<tr>
<th></th>
<th>Today</th>
<th>{day2}</th>
<th>{day3}</th>
</tr>
<tr>
<th>Temperature</th>
<td>{tempday1}</td>
<td>{tempday2}</td>
<td>{tempday3}</td>
</tr>
<tr>
<th>Description</th>
<td>{descday1}</td>
<td>{descday2}</td>
<td>{descday3}</td>
</tr>
<tr>
<th>Wind</th>
<td>{windday1}</td>
<td>{windday2}</td>
<td>{windday3}</td>
</tr>
</table>
<br>
<table>
<tr>
<td>
<p>Bournemouth Pier</p>
<img src="cid:Beach_Image.png" alt="Bournemouth Pier" width="100%" height="50%">
</td>
</tr>
</table>
<br>
<h1>Sea Conditions</h1>
<table>
<tr>
<th>Today</th>
</tr>
<tr>
<td>Wave (m)</td>
<td>{wave1}</td>
</tr>
<tr>
<td>Wave Period (s)</td>
<td>{wave_period1}</td>
</tr>
<tr>
<td>Wind Wave (m)</td>
<td>{wind_wave1}</td>
</tr>
<tr>
<td>Wind Speed (mph)</td>
<td>{oceanwind1}</td>
</tr>
<tr>
</table>
<br>
<table>
<tr>
<th>{day2}</th>
</tr>
<tr>
<td>Wave (m)</td>
<td>{wave2}</td>
</tr>
<tr>
<td>Wave Period (s)</td>
<td>{wave_period2}</td>
</tr>
<tr>
<td>Wind Wave (m)</td>
<td>{wind_wave2}</td>
</tr>
<tr>
<td>Wind Speed (mph)</td>
<td>{oceanwind2}</td>
</tr>
<tr>
</table>
<br>
<table>
<tr>
<th>{day3}</th>
</tr>
<tr>
<td>Wave (m)</td>
<td>{wave3}</td>
</tr>
<tr>
<td>Wave Period (s)</td>
<td>{wave_period3}</td>
</tr>
<tr>
<td>Wind Wave (m)</td>
<td>{wind_wave3}</td>
</tr>
<tr>
<td>Wind Speed (mph)</td>
<td>{oceanwind3}</td>
</tr>
<tr>
</table>
<br>
<table>
<tr>
<th>Water Temperature (°C)</th>
</tr>
<td>{water_temp}</td>
</tr>
</table>
</body>
</html>""".format(day2=dt_now.shift(days=1).format('dddd'),
day3=dt_now.shift(days=2).format('dddd'),
day4=dt_now.shift(days=3).format('dddd'),
day5=dt_now.shift(days=4).format('dddd'),
icon1=weather_forecast[0].get('icon_id'),
icon2=weather_forecast[1].get('icon_id'),
icon3=weather_forecast[2].get('icon_id'),
icon4=weather_forecast[3].get('icon_id'),
icon5=weather_forecast[4].get('icon_id'),
tempday1=weather_forecast[0].get('Temperature'),
tempday2=weather_forecast[1].get('Temperature'),
tempday3=weather_forecast[2].get('Temperature'),
descday1=weather_forecast[0].get('Weather Description'),
descday2=weather_forecast[1].get('Weather Description'),
descday3=weather_forecast[2].get('Weather Description'),
windday1=weather_forecast[0].get('Wind Speed'),
windday2=weather_forecast[1].get('Wind Speed'),
windday3=weather_forecast[2].get('Wind Speed'),
wave1=wave_forecast[0].get('waveHeight'),
wave2=wave_forecast[1].get('waveHeight'),
wave3=wave_forecast[2].get('waveHeight'),
wave_period1=wave_forecast[0].get('swellPeriod'),
wave_period2=wave_forecast[1].get('swellPeriod'),
wave_period3=wave_forecast[2].get('swellPeriod'),
wind_wave1=wave_forecast[0].get('windWaveHeight'),
wind_wave2=wave_forecast[1].get('windWaveHeight'),
wind_wave3=wave_forecast[2].get('windWaveHeight'),
oceanwind1= wave_forecast[0].get('windSpeed'),
oceanwind2=wave_forecast[1].get('windSpeed'),
oceanwind3=wave_forecast[2].get('windSpeed'),
water_temp=wave_forecast[0].get('waterTemperature')
)
return html_str1 + html_str2