ПР2.3: финальная версия (TCP/UDP/HTTP/Wireshark/Gitea)
This commit is contained in:
parent
111c01965d
commit
c4617b05ae
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,14 +1,9 @@
|
|||||||
# виртуальное окружение
|
|
||||||
venv/
|
venv/
|
||||||
.env/
|
.env/
|
||||||
|
|
||||||
# кеши Python
|
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
# файлы среды разработки
|
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
# прочие временные файлы
|
|
||||||
*.log
|
*.log
|
||||||
|
api_git_example.py
|
||||||
|
token.py
|
||||||
@ -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
19
gitea_create_repo.py
Normal 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
13
gitea_read_user.py
Normal 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)
|
||||||
Loading…
Reference in New Issue
Block a user