|
@@ -1,62 +0,0 @@
|
|
|
-from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
|
-from datetime import datetime
|
|
|
-import re
|
|
|
-
|
|
|
-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>Main</title></head>
|
|
|
- <body>Главная страница<br></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>Info student</title></head>
|
|
|
- <body>Timofeeva Darya Dmitrievna gr 701(3).</body></html>"""
|
|
|
-
|
|
|
- self.wfile.write(http_text.encode())
|
|
|
- if self.path.endswith("/Status"):
|
|
|
- self.send_response(200)
|
|
|
-
|
|
|
- add=self.client_address[0]
|
|
|
- add=re.sub('[.]([0-9]{1,3})', ".x", add, 2)
|
|
|
- time=datetime.now().strftime("%Y-%m-%d %I:%M:%S%p")
|
|
|
-
|
|
|
- self.send_header("Content-type", "text/html")
|
|
|
- self.end_headers()
|
|
|
-
|
|
|
- http_text = f"<html><head><meta charset='utf-8'>" \
|
|
|
- f"<title>Status</title></head>" \
|
|
|
- f"<body>Ваш IP: {add}<br>" \
|
|
|
- f"ФИО: Timofeeva Darya Dmitrievnа <br>" \
|
|
|
- f"Дата: {time}</body></html>"
|
|
|
- self.wfile.write(http_text.encode())
|
|
|
-
|
|
|
- except IOError:
|
|
|
- self.send_error(400,f"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("Starting the server!")
|
|
|
- httpd.serve_forever()
|
|
|
-
|
|
|
- except KeyboardInterrupt:
|
|
|
- httpd.server_close()
|
|
|
- print("The server is stopped")
|
|
|
-
|
|
|
-if __name__ == '__main__':
|
|
|
- main()
|