Compare commits
No commits in common. "bda530a6691e1ef0a1fe6e2c3feb9207ab733329" and "3f0e365aa355f6eb7258b3e2ffd5d5a0a7d0783f" have entirely different histories.
bda530a669
...
3f0e365aa3
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 98 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB |
@ -1,8 +0,0 @@
|
|||||||
import socket
|
|
||||||
|
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
client.connect(('127.0.0.1', 10000))
|
|
||||||
client.sendall(b'exit')
|
|
||||||
data = client.recv(1024)
|
|
||||||
print(f"Ответ от сервера: {data.decode()}")
|
|
||||||
client.close()
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
import socket
|
|
||||||
|
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
client.connect(('vyatsu.ru', 80))
|
|
||||||
|
|
||||||
# HTTP запрос КАК В REQUESTS (с полными заголовками)
|
|
||||||
request = (
|
|
||||||
"GET / HTTP/1.1\r\n"
|
|
||||||
"Host: vyatsu.ru\r\n"
|
|
||||||
"User-Agent: python-requests/2.33.1\r\n"
|
|
||||||
"Accept-Encoding: gzip, deflate\r\n"
|
|
||||||
"Accept: */*\r\n"
|
|
||||||
"Connection: keep-alive\r\n"
|
|
||||||
"\r\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
print("ЗАПРОС (как в requests):")
|
|
||||||
print(request)
|
|
||||||
|
|
||||||
# Отправляем запрос
|
|
||||||
client.sendall(request.encode())
|
|
||||||
|
|
||||||
response = client.recv(4096)
|
|
||||||
print("\nОТВЕТ:")
|
|
||||||
print(response.decode())
|
|
||||||
|
|
||||||
client.close()
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
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
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
import requests
|
|
||||||
|
|
||||||
f = open("tokens.txt", 'r+')
|
|
||||||
for i in f:
|
|
||||||
if "readtok" in i:
|
|
||||||
for j in i:
|
|
||||||
TOKEN = i[i.index('-') + 2: -1]
|
|
||||||
headers = {"Authorization": f"token {TOKEN}"}
|
|
||||||
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
|
|
||||||
print(response.json())
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
import requests
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
sys.path.append(r"C:\Users\Максим\Desktop\доки по вузу\2_курс\практика_2\2 задание\venv\Lib\site-packages")
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
TOKEN = os.getenv('writetok')
|
|
||||||
|
|
||||||
if not TOKEN:
|
|
||||||
print("Токен не найден!")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"Authorization": f"token {TOKEN}",
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
|
|
||||||
repo_data = {
|
|
||||||
"name": "Repo_lab3_make_with_api",
|
|
||||||
"description": "Репозиторий создан через API Gitea",
|
|
||||||
"private": False,
|
|
||||||
"auto_init": True
|
|
||||||
}
|
|
||||||
|
|
||||||
print("Создание репозитория...")
|
|
||||||
|
|
||||||
response = requests.post(
|
|
||||||
"https://git.vyatsu.ru/api/v1/user/repos",
|
|
||||||
headers=headers,
|
|
||||||
json=repo_data
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.status_code == 201:
|
|
||||||
repo = response.json()
|
|
||||||
print(f"Репозиторий создан!")
|
|
||||||
print(f"Название: {repo['full_name']}")
|
|
||||||
print(f"URL: {repo['html_url']}")
|
|
||||||
else:
|
|
||||||
print(f"Ошибка: {response.status_code}")
|
|
||||||
print(response.text)
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
import socket
|
|
||||||
|
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
||||||
client.sendto(b'hello server', ('127.0.0.1', 10002))
|
|
||||||
data, _ = client.recvfrom(1024)
|
|
||||||
print(f"Ответ от сервера: {data.decode()}")
|
|
||||||
client.close()
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import socket
|
|
||||||
import time
|
|
||||||
|
|
||||||
counter = 0
|
|
||||||
total_bytes = 0
|
|
||||||
|
|
||||||
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
||||||
server.bind(('0.0.0.0', 10002))
|
|
||||||
print("UDP сервер запущен (со статистикой)")
|
|
||||||
|
|
||||||
while True:
|
|
||||||
data, addr = server.recvfrom(1024)
|
|
||||||
counter += 1
|
|
||||||
total_bytes += len(data)
|
|
||||||
|
|
||||||
original = data.decode()
|
|
||||||
|
|
||||||
modified = f"[#{counter}] [байт:{len(data)}] [всего:{total_bytes}] {original.upper()}"
|
|
||||||
|
|
||||||
print(f"Пакет #{counter} от {addr}: {original} -> {modified}")
|
|
||||||
server.sendto(modified.encode(), addr)
|
|
||||||
Loading…
Reference in New Issue
Block a user