diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e216dd6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.env +*.token +.venv +.idea +__pycache__ \ No newline at end of file diff --git a/GITEAREAD.py b/GITEAREAD.py new file mode 100644 index 0000000..427054b --- /dev/null +++ b/GITEAREAD.py @@ -0,0 +1,11 @@ +import os +import requests +from dotenv import load_dotenv + +load_dotenv() # Загружает переменные из .env + +TOKEN = os.getenv("GITEA_READ_TOKEN") +headers = {"Authorization": f"token {TOKEN}"} +response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers) + +print(response.json()) # Информация о вашем аккаунте \ No newline at end of file diff --git a/GITEAWRITE.py b/GITEAWRITE.py new file mode 100644 index 0000000..084adf7 --- /dev/null +++ b/GITEAWRITE.py @@ -0,0 +1,21 @@ +import os +import requests +from dotenv import load_dotenv + +load_dotenv() + +TOKEN = os.getenv("GITEA_WRITE_TOKEN") +headers = {"Authorization": f"token {TOKEN}"} +data = { + "name": "test-repo", # Уникальное имя + "description": "Repo created via API", + "private": False +} + +response = requests.post( + "https://git.vyatsu.ru/api/v1/user/repos", + headers=headers, + json=data +) + +print(response.status_code, response.json()) \ No newline at end of file diff --git a/REPO.py b/REPO.py new file mode 100644 index 0000000..06833f9 --- /dev/null +++ b/REPO.py @@ -0,0 +1,21 @@ +import os +import requests +from dotenv import load_dotenv + +load_dotenv() + +TOKEN = os.getenv("GITEA_WRITE_TOKEN") +headers = {"Authorization": f"token {TOKEN}"} +data = { + "name": "test-repo", # Уникальное имя + "description": "Создано с помощью апи", + "private": False +} + +response = requests.post( + "https://git.vyatsu.ru/api/v1/user/repos", + headers=headers, + json=data +) + +print(response.status_code, response.json()) \ No newline at end of file diff --git a/TCP SYN SYN,ACK ACK.png b/TCP SYN SYN,ACK ACK.png new file mode 100644 index 0000000..fed540e Binary files /dev/null and b/TCP SYN SYN,ACK ACK.png differ diff --git a/TCP.png b/TCP.png new file mode 100644 index 0000000..e2ef8a8 Binary files /dev/null and b/TCP.png differ diff --git a/TCP2.png b/TCP2.png new file mode 100644 index 0000000..78837e9 Binary files /dev/null and b/TCP2.png differ diff --git a/TCPC.py b/TCPC.py new file mode 100644 index 0000000..9b30b48 --- /dev/null +++ b/TCPC.py @@ -0,0 +1,12 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client.connect(('127.0.0.1', 10000)) + +message = input("Введите сообщение (или 'exit' для завершения сервера): ") +client.sendall(message.encode()) + +data = client.recv(1024) +print(f"Ответ от сервера: {data.decode()}") + +client.close() \ No newline at end of file diff --git a/TCPS.py b/TCPS.py new file mode 100644 index 0000000..1cbe3de --- /dev/null +++ b/TCPS.py @@ -0,0 +1,25 @@ +import socket + +server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +server.bind(("0.0.0.0", 10000)) +server.listen(1) +print("TCP сервер запущен") + +while True: + conn, addr = server.accept() + print(f"Подключение от {addr}") + + data = conn.recv(1024) + if not data: + break + + if data.upper() == b'EXIT': + conn.sendall(b'Server shutting down...') + conn.close() + break + + conn.sendall(data.upper()) + conn.close() + +server.close() +print("TCP сервер остановлен") \ No newline at end of file diff --git a/UDP1.png b/UDP1.png new file mode 100644 index 0000000..41d3431 Binary files /dev/null and b/UDP1.png differ diff --git a/UDP2.png b/UDP2.png new file mode 100644 index 0000000..3805768 Binary files /dev/null and b/UDP2.png differ diff --git a/UDPC.py b/UDPC.py new file mode 100644 index 0000000..98eceed --- /dev/null +++ b/UDPC.py @@ -0,0 +1,11 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +message = input("Введите сообщение: ") +client.sendto(message.encode(), ('127.0.0.1', 20000)) + +data, _ = client.recvfrom(2048) +print(f"Ответ от сервера: {data.decode()}") + +client.close() \ No newline at end of file diff --git a/UDPS.py b/UDPS.py new file mode 100644 index 0000000..2738fba --- /dev/null +++ b/UDPS.py @@ -0,0 +1,18 @@ +import socket + +server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +server.bind(("0.0.0.0", 20000)) +print("UDP сервер запущен") + +while True: + data, addr = server.recvfrom(1024) + print(f"Получено от {addr}: {data.decode()}") + + if data.upper() == b'EXIT': + server.sendto(b'Server shutting down...', addr) + break + + server.sendto(data.upper(), addr) + +server.close() +print("UDP сервер остановлен") \ No newline at end of file diff --git a/http1.png b/http1.png new file mode 100644 index 0000000..98712a5 Binary files /dev/null and b/http1.png differ diff --git a/http21.png b/http21.png new file mode 100644 index 0000000..5b121b0 Binary files /dev/null and b/http21.png differ diff --git a/pyhttp.py b/pyhttp.py new file mode 100644 index 0000000..745f202 --- /dev/null +++ b/pyhttp.py @@ -0,0 +1,21 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client.connect(('vyatsu.ru', 80)) + +# Запрос с заголовками как у requests +request = ( + "GET / HTTP/1.1\r\n" + "Host: vyatsu.ru\r\n" + "User-Agent: python-socket-client/1.0\r\n" + "Accept: */*\r\n" + "Accept-Encoding: gzip, deflate\r\n" + "Connection: keep-alive\r\n" + "\r\n" +) + +client.sendall(request.encode()) + +response = client.recv(4096) +print(response.decode()) +client.close() \ No newline at end of file diff --git a/Снимок экрана 2025-05-16 030854.png b/Снимок экрана 2025-05-16 030854.png new file mode 100644 index 0000000..f3565c9 Binary files /dev/null and b/Снимок экрана 2025-05-16 030854.png differ