feat: complete lab3 network scripts
This commit is contained in:
parent
179f019121
commit
aa6080c4ad
6
HTTP/local_http_client.py
Normal file
6
HTTP/local_http_client.py
Normal file
@ -0,0 +1,6 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://127.0.0.1:8080")
|
||||
|
||||
print("Статус-код:", response.status_code)
|
||||
print("Ответ сервера:", response.text)
|
||||
16
HTTP/local_http_server.py
Normal file
16
HTTP/local_http_server.py
Normal file
@ -0,0 +1,16 @@
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
|
||||
|
||||
class SimpleHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
message = "Hello from local HTTP server"
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header("Content-type", "text/plain; charset=utf-8")
|
||||
self.end_headers()
|
||||
self.wfile.write(message.encode("utf-8"))
|
||||
|
||||
|
||||
server = HTTPServer(("127.0.0.1", 8080), SimpleHandler)
|
||||
print("HTTP сервер запущен: http://127.0.0.1:8080")
|
||||
server.serve_forever()
|
||||
Loading…
Reference in New Issue
Block a user