|
@@ -0,0 +1,34 @@
|
|
|
+from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
|
+
|
|
|
+# Определение обработчика запросов
|
|
|
+class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
|
|
+
|
|
|
+ # Обработка GET-запросов
|
|
|
+ def do_GET(self):
|
|
|
+ if self.path == '/ok': # Страница "OK"
|
|
|
+ self.send_response(200) # HTTP статус 200
|
|
|
+ self.send_header('Content-type', 'text/html')
|
|
|
+ self.end_headers()
|
|
|
+ self.wfile.write(b'OK')
|
|
|
+ elif self.path == '/info': # Страница "Info"
|
|
|
+ self.send_response(200) # HTTP статус 200
|
|
|
+ self.send_header('Content-type', 'text/html')
|
|
|
+ self.end_headers()
|
|
|
+ # Информация о студенте
|
|
|
+ info = "<html><body><h1>Student Info</h1><p>\
|
|
|
+ Name: Sechina Alyona</p><p>Group: 712</p></body></html>"
|
|
|
+ self.wfile.write(info.encode('utf-8'))
|
|
|
+ else: # Обработка для неизвестных страниц
|
|
|
+ self.send_response(404) # HTTP статус 404
|
|
|
+ self.send_header('Content-type', 'text/html')
|
|
|
+ self.end_headers()
|
|
|
+ self.wfile.write(b'404 Not Found')
|
|
|
+
|
|
|
+# Настройка сервера
|
|
|
+HOST = 'localhost'
|
|
|
+PORT = 8080
|
|
|
+
|
|
|
+# Запуск сервера
|
|
|
+server = HTTPServer((HOST, PORT), SimpleHTTPRequestHandler)
|
|
|
+print(f'Server started at http://{HOST}:{PORT}')
|
|
|
+server.serve_forever()
|