Skip to content
This repository was archived by the owner on Dec 24, 2021. It is now read-only.

Commit e77dab9

Browse files
authored
Update log error
1 parent d9fbf11 commit e77dab9

File tree

1 file changed

+88
-88
lines changed

1 file changed

+88
-88
lines changed

code/wasseruhr.py

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
1-
from http.server import HTTPServer, BaseHTTPRequestHandler
2-
from urllib import parse
3-
import lib.ZaehlerstandClass
4-
import os
5-
import subprocess
6-
7-
import socketserver
8-
9-
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
10-
11-
def do_GET(self):
12-
global wasserzaehler
13-
url_parse = parse.urlparse(self.path)
14-
query_parse = parse.parse_qs(url_parse.query)
15-
16-
if 'reload' in url_parse.path:
17-
self.send_response(200)
18-
self.send_header('Content-type', 'text/html')
19-
self.end_headers()
20-
result = 'Konfiguration wird neu geladen'
21-
self.wfile.write(bytes(result, 'UTF-8'))
22-
del wasserzaehler
23-
wasserzaehler = lib.ZaehlerstandClass.Zaehlerstand()
24-
return
25-
26-
27-
if "/image_tmp/" in url_parse.path:
28-
self.send_response(200)
29-
size = str(os.stat('.'+self.path).st_size)
30-
self.send_header('Content-type', 'image/jpg')
31-
self.send_header('Content-length', size)
32-
self.end_headers()
33-
with open('.'+self.path, 'rb') as file:
34-
self.wfile.write(file.read()) # Read the file and send the contents
35-
return
36-
37-
url = ''
38-
if 'url' in query_parse:
39-
url = query_parse['url'][0]
40-
41-
simple = True
42-
if ('&full' in self.path) or ('?full' in self.path):
43-
simple = False
44-
45-
single = False
46-
if ('&single' in self.path) or ('?single' in self.path):
47-
single = True
48-
49-
usePrevalue = False
50-
if ('&usePreValue' in self.path) or ('?usePreValue' in self.path) or ('&usePrevalue' in self.path) or ('?usePrevalue' in self.path):
51-
usePrevalue = True
52-
53-
value = ''
54-
if 'value' in query_parse:
55-
value = query_parse['value'][0]
56-
57-
if ('roi' in url_parse.path) or ('ROI' in url_parse.path):
58-
result = wasserzaehler.getROI(url)
59-
self.send_response(200)
60-
self.send_header('Content-type', 'text/html')
61-
self.end_headers()
62-
self.wfile.write(bytes(result, 'UTF-8'))
63-
return
64-
65-
if 'setPreValue' in url_parse.path:
66-
result = wasserzaehler.setPreValue(value)
67-
self.send_response(200)
68-
self.send_header('Content-type', 'text/html')
69-
self.end_headers()
70-
self.wfile.write(bytes(result, 'UTF-8'))
71-
return
72-
73-
if 'wasserzaehler' in url_parse.path:
74-
result = wasserzaehler.getZaehlerstand(url, simple, usePrevalue, single)
75-
self.send_response(200)
76-
self.send_header('Content-type', 'text/html')
77-
self.end_headers()
78-
self.wfile.write(bytes(result, 'UTF-8'))
79-
return
80-
81-
if __name__ == '__main__':
82-
83-
wasserzaehler = lib.ZaehlerstandClass.Zaehlerstand()
84-
85-
PORT = 3000
86-
with socketserver.TCPServer(("", PORT), SimpleHTTPRequestHandler) as httpd:
87-
print("Wasserzaehler is serving at port", PORT)
88-
httpd.serve_forever()
1+
from http.server import HTTPServer, BaseHTTPRequestHandler
2+
from urllib import parse
3+
import lib.ZaehlerstandClass
4+
import os
5+
import subprocess
6+
7+
import socketserver
8+
9+
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
10+
11+
def do_GET(self):
12+
global wasserzaehler
13+
url_parse = parse.urlparse(self.path)
14+
query_parse = parse.parse_qs(url_parse.query)
15+
16+
if 'reload' in url_parse.path:
17+
self.send_response(200)
18+
self.send_header('Content-type', 'text/html')
19+
self.end_headers()
20+
result = 'Konfiguration wird neu geladen'
21+
self.wfile.write(bytes(result, 'UTF-8'))
22+
del wasserzaehler
23+
wasserzaehler = lib.ZaehlerstandClass.Zaehlerstand()
24+
return
25+
26+
27+
if "/image_tmp/" in url_parse.path:
28+
self.send_response(200)
29+
size = str(os.stat('.'+self.path).st_size)
30+
self.send_header('Content-type', 'image/jpg')
31+
self.send_header('Content-length', size)
32+
self.end_headers()
33+
with open('.'+self.path, 'rb') as file:
34+
self.wfile.write(file.read()) # Read the file and send the contents
35+
return
36+
37+
url = ''
38+
if 'url' in query_parse:
39+
url = query_parse['url'][0]
40+
41+
simple = True
42+
if ('&full' in self.path) or ('?full' in self.path):
43+
simple = False
44+
45+
single = False
46+
if ('&single' in self.path) or ('?single' in self.path):
47+
single = True
48+
49+
usePrevalue = False
50+
if ('&usePreValue' in self.path) or ('?usePreValue' in self.path) or ('&usePrevalue' in self.path) or ('?usePrevalue' in self.path):
51+
usePrevalue = True
52+
53+
value = ''
54+
if 'value' in query_parse:
55+
value = query_parse['value'][0]
56+
57+
if ('roi' in url_parse.path) or ('ROI' in url_parse.path):
58+
result = wasserzaehler.getROI(url)
59+
self.send_response(200)
60+
self.send_header('Content-type', 'text/html')
61+
self.end_headers()
62+
self.wfile.write(bytes(result, 'UTF-8'))
63+
return
64+
65+
if 'setPreValue' in url_parse.path:
66+
result = wasserzaehler.setPreValue(value)
67+
self.send_response(200)
68+
self.send_header('Content-type', 'text/html')
69+
self.end_headers()
70+
self.wfile.write(bytes(result, 'UTF-8'))
71+
return
72+
73+
if 'wasserzaehler' in url_parse.path:
74+
result = wasserzaehler.getZaehlerstand(url, simple, usePrevalue, single)
75+
self.send_response(200)
76+
self.send_header('Content-type', 'text/html')
77+
self.end_headers()
78+
self.wfile.write(bytes(result, 'UTF-8'))
79+
return
80+
81+
if __name__ == '__main__':
82+
83+
wasserzaehler = lib.ZaehlerstandClass.Zaehlerstand()
84+
85+
PORT = 3000
86+
with socketserver.TCPServer(("", PORT), SimpleHTTPRequestHandler) as httpd:
87+
print("Wasserzaehler is serving at port", PORT)
88+
httpd.serve_forever()

0 commit comments

Comments
 (0)