-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
56 lines (54 loc) · 1.7 KB
/
util.py
File metadata and controls
56 lines (54 loc) · 1.7 KB
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
from custom_encoder import CustomEnconder
import json
def buildResponse(statusCode,headers,body=None):
responseObject = {
'statusCode' : statusCode,
'headers': headers
}
if body is not None:
responseObject['body'] = json.dumps(body,cls=CustomEnconder)
return responseObject
def renderHtmlResponse(title, message):
return {
'statusCode': 200,
'headers': {
'Content-Type': 'text/html',
},
'body': f'''
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title}</title>
<style>
body {{
font-family: Arial, sans-serif;
text-align: center;
background-color: #f4f4f4;
}}
.container {{
margin: 100px auto;
max-width: 600px;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}}
h1 {{
color: #333;
}}
p {{
font-size: 18px;
color: #555;
}}
</style>
</head>
<body>
<div class="container">
<h1>{title}</h1>
<p>{message}</p>
</div>
</body>
</html>
''',
}