]> vault307.fbx.one Git - esp32Cam.git/blob - html.py
esp32Camera webserver
[esp32Cam.git] / html.py
1 # The MIT License (MIT)
2 #
3 # Copyright (c) Sharil Tumin
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22 #-----------------------------------------------------------------------------
23
24 # html.py MVC - This is the view V of MVC
25
26 pg = {
27 # URL: /webcam -> /live, /snap -> /foto, /blitz -> /boto
28 'foto':'''<!DOCTYPE html>
29 <html>
30 <head>
31 <title>ESP32 Camera</title>
32 <link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=">
33 </head>
34 <body>
35 <div style="display:flex; margin-top: 15%%; justify-content:center; align-items:center; height:600px;">
36 <img src="%s" style="height:100%%; transform:rotate(%sdeg);"/>
37 </div>
38 </body>
39 </html>
40 ''',
41 'favicon':'''<!DOCTYPE html>
42 <html>
43 <head>
44 <link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=">
45 </head>
46 <body>
47 </body>
48 </html>
49 ''',
50 'err':'''Sorry, I can not do that.
51 ''',
52 'none':'''Sorry, nothing there.
53 ''',
54 'no': '''Sorry, unauthorized.
55 ''',
56 'OK':'''OK!
57 ''',
58 }
59
60 hdr = {
61 # start page for streaming
62 # URL: /webcam, /snap, /blitz
63 'foto': """HTTP/1.1 200 OK
64 Content-Type: text/html; charset=utf-8
65 Connection: Closed
66 Content-Length: %d""",
67 # live stream -
68 # URL: /live
69 'stream': """HTTP/1.1 200 OK
70 Content-Type: multipart/x-mixed-replace; boundary=frame
71 Connection: keep-alive
72 Cache-Control: no-cache, no-store, max-age=0, must-revalidate
73 Expires: Thu, Jan 01 1970 00:00:00 GMT
74 Pragma: no-cache""",
75 # live stream -
76 # URL:
77 'frame': """--frame
78 Content-Type: image/jpeg""",
79 # still picture -
80 # URL: /foto
81 'pix': """HTTP/1.1 200 OK
82 Content-Type: image/jpeg
83 Content-Length: %d""",
84 #
85 'pic': """HTTP/1.1 200 OK
86 Content-Type: image/jpeg""",
87 # no content error
88 # URL: all the rest
89 'none': """HTTP/1.1 400 Bad Request
90 Content-Type: text/plain; charset=utf-8
91 Connection: Closed
92 Content-Length: %d""",
93 # URL: /favicon.ico
94 'favicon': """HTTP/1.1 200 OK
95 Content-Type: text/html; charset=utf-8
96 Connection: Closed
97 Cache-Control: max-age=2592000, public
98 Content-Length: %d""",
99 # bad request error
100 # URL: all the rest
101 'err': """HTTP/1.1 400 Bad Request
102 Content-Type: text/plain; charset=utf-8
103 Connection: Closed
104 Content-Length: %d""",
105 # OK
106 # URL: all the rest
107 'OK': """HTTP/1.1 200 OK
108 Content-Type: text/plain; charset=utf-8
109 Connection: Closed
110 Content-Length: %d""",
111 # NO
112 # URL: not authenticated
113 'NO': """HTTP/1.1 401 Unauthorized
114 Content-Type: text/plain; charset=utf-8
115 Connection: Closed
116 Content-Length: %d""",
117 }