commit message from python script

This commit is contained in:
2023-12-29 16:53:26 +01:00
parent 1214405b27
commit f843a9cff9
2 changed files with 30 additions and 0 deletions

30
webserver/main_02.py Normal file
View File

@@ -0,0 +1,30 @@
# Python 3 server example
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
hostName = "localhost"
serverPort = 8080
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(bytes("<html><head><title>Mein Test</title></head>", "utf-8"))
self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
self.wfile.write(bytes(str("<p>Uhrzeit :" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "</p>",), "utf-8" ))
self.wfile.write(bytes("<body>", "utf-8"))
self.wfile.write(bytes("<p>Hier kommen die Infos rein !!!</p>", "utf-8"))
self.wfile.write(bytes("</body></html>", "utf-8"))
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")