Compare commits
No commits in common. "main" and "master" have entirely different histories.
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.venv/
|
||||
.env
|
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
gitwrite.py
Normal file
23
gitwrite.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": "basargina",
|
||||
"description": "создано",
|
||||
"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())
|
4
http-req.py
Normal file
4
http-req.py
Normal file
@ -0,0 +1,4 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://vyatsu.ru")
|
||||
print(response.text[:500])
|
9
http-vyt.py
Normal file
9
http-vyt.py
Normal file
@ -0,0 +1,9 @@
|
||||
import socket
|
||||
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect(('vyatsu.ru', 80))
|
||||
request = "GET / HTTP/1.1\r\nHost: vyatsu.ru\r\n\r\n"
|
||||
client.sendall(request.encode())
|
||||
response = client.recv(4096)
|
||||
print(response.decode())
|
||||
client.close()
|
9
tcp-clin.py
Normal file
9
tcp-clin.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()
|
17
tcp-serv.py
Normal file
17
tcp-serv.py
Normal file
@ -0,0 +1,17 @@
|
||||
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
|
7
udp-clin.py
Normal file
7
udp-clin.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', 20019))
|
||||
data, _ = client.recvfrom(1024)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.close()
|
13
udp-serv.py
Normal file
13
udp-serv.py
Normal file
@ -0,0 +1,13 @@
|
||||
import socket
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server.bind(('0.0.0.0', 20019))
|
||||
print("UDP сервер запущен")
|
||||
|
||||
while True:
|
||||
data, addr = server.recvfrom(1024)
|
||||
decoded = data.decode()
|
||||
print(f"Сообщение от {addr}: {decoded}")
|
||||
|
||||
response = ' '.join(decoded.upper()) # Добавляем пробелы между символами
|
||||
server.sendto(response.encode(), addr)
|
19
vyt-req.py
Normal file
19
vyt-req.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"))
|
||||
client.close()
|
Loading…
Reference in New Issue
Block a user