Готово
This commit is contained in:
parent
d1657e0c45
commit
06623c540f
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.env
|
||||
*.token
|
||||
.venv
|
||||
.idea
|
||||
__pycache__
|
11
GITEAREAD.py
Normal file
11
GITEAREAD.py
Normal file
@ -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()) # Информация о вашем аккаунте
|
21
GITEAWRITE.py
Normal file
21
GITEAWRITE.py
Normal file
@ -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())
|
21
REPO.py
Normal file
21
REPO.py
Normal file
@ -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())
|
BIN
TCP SYN SYN,ACK ACK.png
Normal file
BIN
TCP SYN SYN,ACK ACK.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
12
TCPC.py
Normal file
12
TCPC.py
Normal file
@ -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()
|
25
TCPS.py
Normal file
25
TCPS.py
Normal file
@ -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 сервер остановлен")
|
11
UDPC.py
Normal file
11
UDPC.py
Normal file
@ -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()
|
18
UDPS.py
Normal file
18
UDPS.py
Normal file
@ -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 сервер остановлен")
|
BIN
http21.png
Normal file
BIN
http21.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 136 KiB |
21
pyhttp.py
Normal file
21
pyhttp.py
Normal file
@ -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()
|
BIN
Снимок экрана 2025-05-16 030854.png
Normal file
BIN
Снимок экрана 2025-05-16 030854.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
Loading…
Reference in New Issue
Block a user