-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathhtml.py
119 lines (114 loc) · 3.38 KB
/
html.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
# The MIT License (MIT)
#
# Copyright (c) Sharil Tumin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-----------------------------------------------------------------------------
# html.py MVC - This is the view V of MVC
pg = {
# URL: /webcam -> /live, /snap -> /foto, /blitz -> /boto
'foto':'''<!DOCTYPE html>
<html>
<head>
<title>ESP32 Camera</title>
<link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=">
</head>
<body>
<div style="display:flex; margin-top: 15%%; justify-content:center; align-items:center; height:600px;">
<img src="%s" style="height:100%%; transform:rotate(%sdeg);"/>
</div>
</body>
</html>
''',
'favicon':'''<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=">
</head>
<body>
</body>
</html>
''',
'err':'''Sorry, I can not do that.
''',
'none':'''Sorry, nothing there.
''',
'no': '''Sorry, unauthorized.
''',
'OK':'''OK!
''',
}
hdr = {
# start page for streaming
# URL: /webcam, /snap, /blitz
'foto': """HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Connection: Closed
Content-Length: %d""",
# live stream -
# URL: /live
'stream': """HTTP/1.1 200 OK
Content-Type: multipart/x-mixed-replace; boundary=frame
Connection: keep-alive
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: Thu, Jan 01 1970 00:00:00 GMT
Pragma: no-cache""",
# live stream -
# URL:
'frame': """--frame
Content-Type: image/jpeg""",
# still picture -
# URL: /foto
'pix': """HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: %d""",
#
'pic': """HTTP/1.1 200 OK
Content-Type: image/jpeg""",
# no content error
# URL: all the rest
'none': """HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: Closed
Content-Length: %d""",
# URL: /favicon.ico
'favicon': """HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Connection: Closed
Cache-Control: max-age=2592000, public
Content-Length: %d""",
# bad request error
# URL: all the rest
'err': """HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: Closed
Content-Length: %d""",
# OK
# URL: all the rest
'OK': """HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Connection: Closed
Content-Length: %d""",
# NO
# URL: not authenticated
'NO': """HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
Connection: Closed
Content-Length: %d""",
}