Проект полностью реализован
This commit is contained in:
parent
ccf0ca3e3b
commit
a6907d1544
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
venv/
|
||||
.env
|
||||
|
BIN
__pycache__/token.cpython-313.pyc
Normal file
BIN
__pycache__/token.cpython-313.pyc
Normal file
Binary file not shown.
5
http_requests.py
Normal file
5
http_requests.py
Normal file
@ -0,0 +1,5 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://vyatsu.ru")
|
||||
print(response.text[:500])
|
||||
|
17
http_serv.py
Normal file
17
http_serv.py
Normal file
@ -0,0 +1,17 @@
|
||||
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\r\n"
|
||||
"Accept: */*\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
"\r\n"
|
||||
)
|
||||
client.sendall(request.encode())
|
||||
response = client.recv(4096)
|
||||
print(response.decode(errors="ignore"))
|
||||
client.close()
|
30
issue.py
Normal file
30
issue.py
Normal file
@ -0,0 +1,30 @@
|
||||
import os
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Загружаем переменные окружения из .env
|
||||
load_dotenv()
|
||||
|
||||
TOKEN = os.getenv("Git_token")
|
||||
USERNAME = "stud179280"
|
||||
REPO = "3zadanie"
|
||||
|
||||
url = f"https://git.vyatsu.ru/api/v1/repos/{USERNAME}/{REPO}/issues"
|
||||
headers = {
|
||||
"Authorization": f"token {TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
data = {
|
||||
"title": "Тестовая задача от Python",
|
||||
"body": "Эта задача была создана через Gitea API с помощью requests",
|
||||
"assignees": [USERNAME]
|
||||
}
|
||||
|
||||
response = requests.post(url, json=data, headers=headers)
|
||||
|
||||
if response.status_code == 201:
|
||||
print("Задача успешно создана!")
|
||||
print("URL:", response.json().get("html_url"))
|
||||
else:
|
||||
print("Ошибка при создании задачи:", response.status_code)
|
||||
print(response.text)
|
27
repo.py
Normal file
27
repo.py
Normal file
@ -0,0 +1,27 @@
|
||||
import os
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
token = os.getenv("Git_token")
|
||||
if not token:
|
||||
raise ValueError("Токен не найден в переменной окружения Git_token")
|
||||
|
||||
headers = {
|
||||
"Authorization": f"token {token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
repo_data = {
|
||||
"name": "repo3zad",
|
||||
"description": "Репозиторий создан через Gitea",
|
||||
"private": False,
|
||||
"auto_init": True
|
||||
}
|
||||
|
||||
url = "https://git.vyatsu.ru/api/v1/user/repos"
|
||||
response = requests.post(url, headers=headers, json=repo_data)
|
||||
|
||||
print("Статус:", response.status_code)
|
||||
print("Ответ:", response.json())
|
10
tcp_client.py
Normal file
10
tcp_client.py
Normal file
@ -0,0 +1,10 @@
|
||||
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)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.sendall(b'exit')
|
||||
client.close()
|
||||
|
10
tcp_client.py.save
Normal file
10
tcp_client.py.save
Normal file
@ -0,0 +1,10 @@
|
||||
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)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.sendall(b'exit')
|
||||
client.close()
|
||||
|
23
tcp_server.py
Normal file
23
tcp_server.py
Normal file
@ -0,0 +1,23 @@
|
||||
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
|
||||
conn.sendall(data.upper())
|
||||
|
||||
conn.close()
|
||||
|
||||
if data.upper() == b'EXIT':
|
||||
break
|
||||
|
||||
|
6
token_size.py
Normal file
6
token_size.py
Normal file
@ -0,0 +1,6 @@
|
||||
import requests
|
||||
|
||||
TOKEN = "53aed57f1cffb0903ae537edc1b579ff1b0c947f"
|
||||
headers = {"Authorization": f"token {TOKEN}"}
|
||||
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
|
||||
print(response.json())
|
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', 10101))
|
||||
data, _ = client.recvfrom(1024)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.close()
|
12
udp_server.py
Normal file
12
udp_server.py
Normal file
@ -0,0 +1,12 @@
|
||||
import socket
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server.bind(('0.0.0.0', 10101))
|
||||
print("UDP сервер запущен")
|
||||
|
||||
while True:
|
||||
data, addr = server.recvfrom(1024)
|
||||
message = data.decode()
|
||||
print(f"Получено от {addr}: {message}")
|
||||
modified = message.upper()[::-1]
|
||||
server.sendto(modified.encode(), addr)
|
Loading…
Reference in New Issue
Block a user