Добавили все файлы
This commit is contained in:
parent
4cf4d5c444
commit
e2b1e8717a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.venv/
|
||||
.env
|
6
apitok.py
Normal file
6
apitok.py
Normal file
@ -0,0 +1,6 @@
|
||||
import requests
|
||||
|
||||
TOKEN = "3ddeb363b424bcfef3a9cba91e2eaff46673896b"
|
||||
headers = {"Authorization": f"token {TOKEN}"}
|
||||
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
|
||||
print(response.json())
|
4
cli.py
Normal file
4
cli.py
Normal file
@ -0,0 +1,4 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://vyatsu.ru")
|
||||
print(response.text[:500])
|
9
tcpcli.py
Normal file
9
tcpcli.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()
|
7
tcpclient.py
Normal file
7
tcpclient.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()
|
10
tcpserv.py
Normal file
10
tcpserv.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 сервер запущен")
|
||||
|
||||
while True:
|
||||
data, addr = server.recvfrom(1024)
|
||||
print(f"Сообщение от {addr}: {data.decode()}")
|
||||
server.sendto(data.upper(), addr)
|
16
token rw.py
Normal file
16
token rw.py
Normal file
@ -0,0 +1,16 @@
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
load_dotenv()
|
||||
TOKEN = os.getenv("GITEA_rw_TOKEN")
|
||||
headers = {"Authorization": f"token {TOKEN}"}
|
||||
|
||||
data = {
|
||||
"name": "repoZadanie4_rabota_s_Gitea_3laba",
|
||||
"private": False,
|
||||
"description": "Репозиторий, созданный с помощью API"
|
||||
}
|
||||
|
||||
response = requests.post("https://git.vyatsu.ru/api/v1/user/repos", headers=headers, json=data)
|
||||
print(response.json())
|
9
token_read.py
Normal file
9
token_read.py
Normal file
@ -0,0 +1,9 @@
|
||||
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())
|
Loading…
Reference in New Issue
Block a user