32 lines
710 B
Python
32 lines
710 B
Python
import requests
|
|
|
|
data = open("token.env", "r").readlines()
|
|
for line in data:
|
|
if "WRITE_TOKEN" in line:
|
|
TOKEN = line.strip().split("=")[1]
|
|
|
|
headers = {
|
|
"Authorization": f"token {TOKEN}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
repo_data = {
|
|
"name": "3laba_create_by_API",
|
|
"description": "Репозиторий создан через API",
|
|
"private": False
|
|
}
|
|
|
|
response = requests.post(
|
|
"https://git.vyatsu.ru/api/v1/user/repos",
|
|
headers=headers,
|
|
json=repo_data
|
|
)
|
|
|
|
if response.status_code == 201:
|
|
print("Репозиторий создан!")
|
|
print(response.json()["html_url"])
|
|
else:
|
|
print(f"Ошибка: {response.status_code}")
|
|
print(response.text)
|
|
|