Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import socket

def client_hello():
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client_socket.sendto(b"Hello, server", ("localhost", 9090))
response, _ = client_socket.recvfrom(1024)
print(f"Ответ сервера: {response.decode()}")

if __name__ == '__main__':
client_hello()
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import socket

def server_hello():
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_socket.bind(("localhost", 9090))
print("Cервер запущен на порту 9090")

while True:
message, client_address = server_socket.recvfrom(1024)
print(f"Получено сообщение: {message.decode()} от {client_address}")
server_socket.sendto(b"Hello, client", client_address)

if __name__ == '__main__':
server_hello()
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import socket

def client_Pifagor():
a = input("Введите катет a: ")
b = input("Введите катет b: ")
message = f'{a},{b}'
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client_socket.sendto(message.encode(), ("localhost", 9090))

response, _ = client_socket.recvfrom(1024)

print(response.decode())

if __name__ == '__main__':
client_Pifagor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import socket

def server_Pifagor():
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_socket.bind(("localhost", 9090))

while True:
message,client_address = server_socket.recvfrom(1024)
a,b = message.decode().strip().split(',')
a = float(a)
b = float(b)
c = (a**2 + b**2)** 0.5
response = f"Гипотенуза = {c}"
server_socket.sendto(response.encode(),client_address)

if __name__ == '__main__':
server_Pifagor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Язев Г.А.</title>
</head>
<link rel="stylesheet" href="style.css">
<body>

<h2></h2>

<div id="image-container">
<img src="web_lab5.png" usemap="#image-map" alt="Карта" id="main-image">
<img id="png-overlay" src="экран_ненорм.png" alt="Overlay PNG">
</div>

<map name="image-map">
<!-- Воспроизведение аудио 1-->
<area shape="poly" coords="1093,649,881,652,884,451,1091,455" onclick="playAudio('sound1.mp3')" href="#">

<!-- Воспроизведение аудио 2 -->
<area shape="circle" coords="1261,536,125" onclick="playAudio('sound2.mp3')" href="#">

<!-- Всплывающее окно -->
<area shape="poly" coords="699,511,740,584,787,508" onclick="showPopup()" href="#">

<!--Отобразит PNG -->
<area shape="rect" coords="801,699,703,911" onclick="showPNG()" href="#">

<!--Ссылка на сайт-->
<area shape="rect" coords="569,28,1403,542" href="https://yandex.ru/pogoda/2?lat=59.969051&lon=30.431837&utm_source=serp&utm_campaign=helper&utm_medium=desktop&utm_content=helper_desktop_main&utm_term=title" target="_blank">
</map>

<div id="popup">Осторожно, горячо!</div>

<audio id="audio-player" src=""></audio>

<script>
let audio = document.getElementById('audio-player');
let audioTimeout;
function playAudio(src) {
audio.pause();
audio.currentTime = 0;
audio.src = src;
audio.volume = 0.25;
audio.play();
if (audioTimeout) {
clearTimeout(audioTimeout);
}


audio.onplaying = () => {
audioTimeout = setTimeout(() => {
audio.pause();
audio.currentTime = 0;
}, 33000);
};

audio.play().catch(error => {
console.error("Ошибка при воспроизведении:", error);
});
}
function showPopup() {
const popup = document.getElementById('popup');
popup.style.display = 'block';
setTimeout(() => popup.style.display = 'none', 5000);
}

function showPNG() {
const overlay = document.getElementById('png-overlay');
overlay.style.display = 'block';
setTimeout(() => overlay.style.display = 'none', 10000);
}
</script>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import http.server
import socketserver

PORT = 9090

class MyHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == "/":
self.path = "index.html"
return super().do_GET()

with socketserver.TCPServer(("", PORT), MyHandler) as httpd:
print(f"Сервер запущен на порту {PORT}")
httpd.serve_forever()
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #f0f0f0;
text-align: center;
}

h2 {
margin-top: 20px;
color: #333;
}

#image-container {
position: relative;
display: inline-block;
margin-top: 20px;
}

#main-image {
max-width: 100%;
height: auto;
border: 3px solid #aaa;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
}


#popup {
position: absolute;
top: 555px;
left: 1300px;
background-color: rgba(0, 0, 0, 0.75);
padding: 14px 22px;
border: 3px solid #fff;
border-radius: 12px;
box-shadow: 0 0 20px rgba(0,0,0,0.5);
font-size: 20px;
font-weight: bold;
color: #fff;
text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
display: none;
z-index: 10;
max-width: 300px;
text-align: center;
}


#png-overlay {
position: absolute;
top: 357px;
left: 259px;
width: 181px;
height: auto;
display: none;
z-index: 9;
border: 2px solid #000;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import socket
import threading

def receive_messages(sock):
while True:
try:
message = sock.recv(1024).decode()
print("\n" + message)
except:
print("Отключение от сервера.")
sock.close()
break

def send_messages(sock, nickname):
while True:
message = input()
full_message = f"{nickname}: {message}"
sock.send(full_message.encode())

def start_client():
host = "localhost"
port = 9090
nickname = input("Введите ваше имя: ")

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((host, port))

thread_recv = threading.Thread(target=receive_messages, args=(client_socket,))
thread_recv.start()

thread_send = threading.Thread(target=send_messages, args=(client_socket, nickname))
thread_send.start()

if __name__ == "__main__":
start_client()
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import socket
import threading

clients = []

def handle_client(client_socket, address):
print(f"[+] Подключен: {address}")
while True:
try:
message = client_socket.recv(1024)
if not message:
break
broadcast(message, client_socket)
except:
break
print(f"[-] Отключен: {address}")
clients.remove(client_socket)
client_socket.close()

def broadcast(message, sender_socket):
for client in clients:
if client != sender_socket:
try:
client.send(message)
except:
pass

def start_server():
host = "localhost"
port = 9090
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((host, port))
server.listen()

print(f"Сервер запущен на {host}:{port}")

while True:
client_socket, addr = server.accept()
clients.append(client_socket)
thread = threading.Thread(target=handle_client, args=(client_socket, addr))
thread.start()

if __name__ == "__main__":
start_server()
11 changes: 0 additions & 11 deletions work/номер_группы/ФИО/номер_лабы/index.html

This file was deleted.