Весь написанный код

This commit is contained in:
Ренат Гареев 2026-05-07 00:56:53 +03:00
parent 131cb3e8d1
commit 93e33b170b
12 changed files with 113 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.venv/
.idea/
config.py

28
.idea/workspace.xml generated
View File

@ -2,18 +2,30 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7f0d271a-9649-40a6-aaab-cd9fa9e7d8b2" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.idea/PythonProject.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/httpclient.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/httprequests.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/readtoken.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/tcpklient.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/tcpserver.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/udpklient.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/udpserver.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/writetoken.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@ -28,6 +40,10 @@
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ModuleVcsDetector.initialDetectionPerformed": "true",
"Python.tcpklient.executor": "Run",
"Python.tcpserver.executor": "Run",
"Python.udpklient.executor": "Run",
"Python.udpserver.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
"RunOnceActivity.git.unshallow": "true",

View File

@ -0,0 +1,8 @@
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()

Binary file not shown.

13
httpclient.py Normal file
View File

@ -0,0 +1,13 @@
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.33.1\r\n"
"Accept: */*\r\n"
"Connection: close\r\n"
"\r\n"
)
client.sendall(request.encode())
response = client.recv(4096)
print(response.decode())
client.close()

4
httprequests.py Normal file
View File

@ -0,0 +1,4 @@
import requests
response = requests.get("http://vyatsu.ru")
print(response.text[:500])

6
readtoken.py Normal file
View File

@ -0,0 +1,6 @@
import requests
from config import TOKEN
headers = {"Authorization": f"token {TOKEN}"}
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
print(response.json())

8
tcpklient.py Normal file
View File

@ -0,0 +1,8 @@
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()

21
tcpserver.py Normal file
View File

@ -0,0 +1,21 @@
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
udpklient.py Normal file
View File

@ -0,0 +1,7 @@
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.sendto(b'hello server and someone else', ('127.0.0.1', 10006))
data, _ = client.recvfrom(1024)
print(f"Ответ от сервера: {data.decode()}")
client.close()

10
udpserver.py Normal file
View File

@ -0,0 +1,10 @@
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server.bind(('0.0.0.0', 10006))
print("UDP сервер запущен")
while True:
data, addr = server.recvfrom(1024)
print(f"Сообщение от {addr}: {data.decode()}")
server.sendto(data.title(), addr)

12
writetoken.py Normal file
View File

@ -0,0 +1,12 @@
import requests
from config import TOKEN2
headers = {"Authorization": f"token {TOKEN2}", "Content-Type": "application/json"}
# Замените на свои данные
owner = "stud208127"
repo = "zadaniee3"
data = {
"title": "Тестовый issue через API",
"body": "Это issue создан автоматически через Python"
}
response = requests.post(f"https://git.vyatsu.ru/api/v1/repos/stud208127/zadaniee3/issues", headers=headers, json=data)
print(response.json())