Трифонов Адам Леонидович пре 2 година
комит
41947fdd7c
3 измењених фајлова са 52 додато и 0 уклоњено
  1. 5 0
      .gitignore
  2. 47 0
      main.py
  3. BIN
      Отчет лаба АСОС Трифонов А.Л. 701(3) (BASE).docx

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.idea
+
+desktop.ini
+Google Chrome.lnk
+Ссылки на программы.lnk

+ 47 - 0
main.py

@@ -0,0 +1,47 @@
+from http.server import HTTPServer, BaseHTTPRequestHandler
+
+
+class HttpGethandler(BaseHTTPRequestHandler):
+    def do_GET(self):
+        try:
+            if self.path.endswith("/OK"):
+                self.send_response(200)
+
+                self.send_header("Content-type", "text/html")
+                self.end_headers()
+
+                http_text = """<html><head><meta charset='utf-8'
+                                <title>Есть</title></head>
+                                <body>Работает.</body></html>"""
+
+                self.wfile.write(http_text.encode())
+
+            if self.path.endswith("/info"):
+                self.send_response(200)
+
+                self.send_header("Content-type", "text/html")
+                self.end_headers()
+
+                http_text = """<html><head><meta charset='utf-8'
+                                <title>Трифонов А.Л. 701(3)</title></head></html>"""
+
+                self.wfile.write(http_text.encode())
+
+        except IOError:
+            self.send_error(400, f"Не нашел{self.path}")
+
+
+def main(server_class=HTTPServer, handler_class=HttpGethandler):
+    server_address = ('localhost', 8000)
+    httpd = server_class(server_address, handler_class)
+    try:
+        print("Поехали!")
+        httpd.serve_forever()
+
+    except KeyboardInterrupt:
+        httpd.server_close()
+        print("Стоять!")
+
+
+if __name__ == '__main__':
+    main()

BIN
Отчет лаба АСОС Трифонов А.Л. 701(3) (BASE).docx