Завершение третьей работы
This commit is contained in:
		
							parent
							
								
									9e1b1385ad
								
							
						
					
					
						commit
						b014497588
					
				
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1 +1,2 @@
 | 
			
		||||
.venv/
 | 
			
		||||
.venv/
 | 
			
		||||
.env
 | 
			
		||||
							
								
								
									
										6
									
								
								.ipynb_checkpoints/Untitled-checkpoint.ipynb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.ipynb_checkpoints/Untitled-checkpoint.ipynb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
 "cells": [],
 | 
			
		||||
 "metadata": {},
 | 
			
		||||
 "nbformat": 4,
 | 
			
		||||
 "nbformat_minor": 5
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								.ipynb_checkpoints/pr3-checkpoint.ipynb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.ipynb_checkpoints/pr3-checkpoint.ipynb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
 "cells": [],
 | 
			
		||||
 "metadata": {},
 | 
			
		||||
 "nbformat": 4,
 | 
			
		||||
 "nbformat_minor": 5
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										0
									
								
								.ipynb_checkpoints/Практика3-checkpoint.docx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								.ipynb_checkpoints/Практика3-checkpoint.docx
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										4
									
								
								HTTP_requests_client.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								HTTP_requests_client.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
import requests
 | 
			
		||||
 | 
			
		||||
response = requests.get("http://vyatsu.ru")
 | 
			
		||||
print(response.text[:500])
 | 
			
		||||
							
								
								
									
										19
									
								
								HTTP_socket_client.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								HTTP_socket_client.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
import socket
 | 
			
		||||
 | 
			
		||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
			
		||||
client.connect(('vyatsu.ru', 80))
 | 
			
		||||
 | 
			
		||||
request = (
 | 
			
		||||
    "GET / HTTP/1.1\r\n"
 | 
			
		||||
    "Host: vyatsu.ru\r\n"
 | 
			
		||||
    "User-Agent: python-requests/2.31.0\r\n"
 | 
			
		||||
    "Accept-Encoding: gzip, deflate, br\r\n"
 | 
			
		||||
    "Accept: */*\r\n"
 | 
			
		||||
    "Connection: keep-alive\r\n"
 | 
			
		||||
    "\r\n"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
client.sendall(request.encode())
 | 
			
		||||
response = client.recv(4096)
 | 
			
		||||
print(response.decode(errors="replace"))  # Используем replace на случай кодировки gzip
 | 
			
		||||
client.close()
 | 
			
		||||
							
								
								
									
										9
									
								
								TCP_client.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								TCP_client.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
import socket
 | 
			
		||||
 | 
			
		||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 | 
			
		||||
client.connect(('127.0.0.1', 10000))
 | 
			
		||||
client.sendall(b'hello server')
 | 
			
		||||
data = client.recv(1024)
 | 
			
		||||
client.sendall(b'EXIT')
 | 
			
		||||
print(f"Ответ от сервера: {data.decode()}")
 | 
			
		||||
client.close()
 | 
			
		||||
							
								
								
									
										19
									
								
								TCP_server.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								TCP_server.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
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:
 | 
			
		||||
        print("Отключение")
 | 
			
		||||
        break
 | 
			
		||||
    conn.sendall(data.upper())
 | 
			
		||||
    conn.close()
 | 
			
		||||
    if data.upper() == b'EXIT':
 | 
			
		||||
        print("Отключение")
 | 
			
		||||
        break
 | 
			
		||||
							
								
								
									
										7
									
								
								UDP_client.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								UDP_client.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
import socket
 | 
			
		||||
 | 
			
		||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 | 
			
		||||
client.sendto(b'hello server', ('127.0.0.1', 20001))
 | 
			
		||||
data, _ = client.recvfrom(1024)
 | 
			
		||||
print(f"Ответ от сервера: {data.decode()}")
 | 
			
		||||
client.close()
 | 
			
		||||
							
								
								
									
										10
									
								
								UDP_server.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								UDP_server.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
import socket
 | 
			
		||||
 | 
			
		||||
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 | 
			
		||||
server.bind(('0.0.0.0', 20001))
 | 
			
		||||
print("UDP сервер запущен")
 | 
			
		||||
 | 
			
		||||
while True:
 | 
			
		||||
    data, addr = server.recvfrom(1024)
 | 
			
		||||
    print(f"Сообщение от {addr}: {data.decode()}")
 | 
			
		||||
    server.sendto(data.upper(), addr)
 | 
			
		||||
							
								
								
									
										18
									
								
								gitea_read.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								gitea_read.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
import os
 | 
			
		||||
import requests
 | 
			
		||||
from dotenv import load_dotenv
 | 
			
		||||
 | 
			
		||||
# Загрузка переменных окружения из .env
 | 
			
		||||
load_dotenv()
 | 
			
		||||
 | 
			
		||||
# Получение токена из переменной окружения
 | 
			
		||||
TOKEN = os.getenv("GITEA_TOKEN")
 | 
			
		||||
 | 
			
		||||
# Заголовок авторизации
 | 
			
		||||
headers = {"Authorization": f"token {TOKEN}"}
 | 
			
		||||
 | 
			
		||||
# Запрос информации о пользователе
 | 
			
		||||
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
 | 
			
		||||
 | 
			
		||||
# Вывод результата
 | 
			
		||||
print(response.json())
 | 
			
		||||
							
								
								
									
										23
									
								
								gitea_write.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								gitea_write.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
import os
 | 
			
		||||
import requests
 | 
			
		||||
from dotenv import load_dotenv
 | 
			
		||||
 | 
			
		||||
load_dotenv()
 | 
			
		||||
 | 
			
		||||
TOKEN = os.getenv("GITEA_TOKEN_WRITE")
 | 
			
		||||
headers = {
 | 
			
		||||
    "Authorization": f"token {TOKEN}",
 | 
			
		||||
    "Content-Type": "application/json"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
repo_data = {
 | 
			
		||||
    "name": "my-new-repo",
 | 
			
		||||
    "description": "Создано через API Gitea",
 | 
			
		||||
    "private": False,
 | 
			
		||||
    "auto_init": True
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
response = requests.post("https://git.vyatsu.ru/api/v1/user/repos", headers=headers, json=repo_data)
 | 
			
		||||
 | 
			
		||||
print(response.status_code)
 | 
			
		||||
print(response.json())
 | 
			
		||||
							
								
								
									
										6
									
								
								pr3.ipynb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								pr3.ipynb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
 "cells": [],
 | 
			
		||||
 "metadata": {},
 | 
			
		||||
 "nbformat": 4,
 | 
			
		||||
 "nbformat_minor": 5
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								~$актика3.docx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								~$актика3.docx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Практика3.docx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Практика3.docx
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user