ПР2.3: финальная версия (TCP/UDP/HTTP/Wireshark/Gitea)

This commit is contained in:
Михаил Огнев 2026-05-23 23:50:45 +03:00
parent 111c01965d
commit c4617b05ae
5 changed files with 41 additions and 16 deletions

11
.gitignore vendored
View File

@ -1,14 +1,9 @@
# виртуальное окружение
venv/
.env/
# кеши Python
__pycache__/
*.pyc
# файлы среды разработки
.vscode/
.idea/
# прочие временные файлы
*.log
*.log
api_git_example.py
token.py

View File

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

19
gitea_create_repo.py Normal file
View File

@ -0,0 +1,19 @@
import os
import requests
TOKEN = os.getenv("GITEA_WRITE_TOKEN")
headers = {
"Authorization": f"token {TOKEN}",
"Content-Type": "application/json"
}
data = {
"name": "lab3-api-repo",
"description": "Репозиторий создан через Gitea API",
"private": False,
"auto_init": True
}
response = requests.post("https://git.vyatsu.ru/api/v1/user/repos", json=data, headers=headers)
print(response.status_code)
print(response.json())

13
gitea_read_user.py Normal file
View File

@ -0,0 +1,13 @@
import os
import requests
TOKEN = os.getenv("GITEA_READ_TOKEN")
if not TOKEN:
raise RuntimeError("Переменная окружения GITEA_READ_TOKEN не задана")
headers = {"Authorization": f"token {TOKEN}"}
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
print(response.status_code)
print(response.text)

View File

@ -1,8 +0,0 @@
import os
import requests
TOKEN = os.getenv("GIT_VYATSU_TOKEN") # токен через переменную окружения
headers = {"Authorization": f"token {TOKEN}"}
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
print(response.json())