|
@@ -0,0 +1,33 @@
|
|
|
+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>Страница 2</title></head>
|
|
|
+ <body>Смагин Максим Сергеевич 701 группа</body></html>"""
|
|
|
+ self.wfile.write(http_text.encode()))
|
|
|
+ except IOError:
|
|
|
+ self.send_error(400, "File not found{self.path}")
|
|
|
+def main(server_class=HTTPServer,handler_class=HttpGetHandler):
|
|
|
+ server_address = ('localhost', 8000)
|
|
|
+ httpd = server_class(server_address,handler_class)
|
|
|
+ try:
|
|
|
+ print("Start!")
|
|
|
+ httpd.serve_forever()
|
|
|
+ except KeyboardInterrupt:
|
|
|
+ httpd.server_close()
|
|
|
+ print("Stop!")
|
|
|
+if __name__ == "__main__":
|
|
|
+ main()
|