Добавление файлов
This commit is contained in:
parent
b06d3df5b0
commit
5f2d5fc62d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
venv/
|
||||
.env
|
||||
__pycache__/
|
||||
|
1
.ipynb_checkpoints/README-checkpoint.md
Normal file
1
.ipynb_checkpoints/README-checkpoint.md
Normal file
@ -0,0 +1 @@
|
||||
ewe
|
1
Practika2
Submodule
1
Practika2
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6c0d01285536b781470abf7e141831514f8c182f
|
7
tcp_client.py
Normal file
7
tcp_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', 10001))
|
||||
data, _ = client.recvfrom(1024)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.close()
|
9
tcp_client2.py
Normal file
9
tcp_client2.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()
|
4
tcp_client3.py
Normal file
4
tcp_client3.py
Normal file
@ -0,0 +1,4 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://vyatsu.ru")
|
||||
print(response.text[:500])
|
10
tcp_client4.py
Normal file
10
tcp_client4.py
Normal file
@ -0,0 +1,10 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
import requests
|
||||
|
||||
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())
|
16
tcp_client5.py
Normal file
16
tcp_client5.py
Normal file
@ -0,0 +1,16 @@
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
load_dotenv()
|
||||
TOKEN = os.getenv("GITEA_TOKEN_WRITE")
|
||||
headers = {"Authorization": f"token {TOKEN}"}
|
||||
|
||||
data = {
|
||||
"name": "praktica3rabotaAPI",
|
||||
"private": False,
|
||||
"description": "Создание репозитория, созданный с помощью API"
|
||||
}
|
||||
|
||||
response = requests.post("https://git.vyatsu.ru/api/v1/user/repos", headers=headers, json=data)
|
||||
print(response.json())
|
10
tcp_server.py
Normal file
10
tcp_server.py
Normal file
@ -0,0 +1,10 @@
|
||||
import socket
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server.bind(('0.0.0.0', 13001))
|
||||
print("UDP сервер запущен на порту 13001")
|
||||
|
||||
while True:
|
||||
data, addr = server.recvfrom(1024)
|
||||
print(f"Сообщение от {addr}: {data.decode()}")
|
||||
server.sendto(data.upper(), addr)
|
Loading…
Reference in New Issue
Block a user