|
@@ -1,5 +1,6 @@
|
|
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
|
-
|
|
|
+from datetime import datetime
|
|
|
+import re
|
|
|
|
|
|
class HttpGetHandler(BaseHTTPRequestHandler):
|
|
|
def do_GET(self):
|
|
@@ -13,7 +14,8 @@ class HttpGetHandler(BaseHTTPRequestHandler):
|
|
|
http_text = """<html><head><meta charset='utf-8'>
|
|
|
<title>Main</title></head>
|
|
|
<body>Главная страница<br>
|
|
|
- <a href="http://localhost:8000/Info">Info</a></body><html>"""
|
|
|
+ <a href="http://localhost:8000/Info">Info</a></body><html><br>
|
|
|
+ <a href="http://localhost:8000/Status">Status</a></body><html>"""
|
|
|
|
|
|
self.wfile.write(http_text.encode())
|
|
|
if self.path.endswith("/Info"):
|
|
@@ -28,6 +30,23 @@ class HttpGetHandler(BaseHTTPRequestHandler):
|
|
|
<a href="http://localhost:8000/">На главную</a></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"ФИО: Чичкова Виорика Владимировна <br>" \
|
|
|
+ f"Дата: {time}<br><br>" \
|
|
|
+ f"<a href='http://localhost:8000/'>На главную</body></html>"
|
|
|
+ self.wfile.write(http_text.encode())
|
|
|
|
|
|
except IOError:
|
|
|
self.send_error(400,f"File not found{self.path}")
|