GItea
This commit is contained in:
parent
c3417ce6a9
commit
0dd572c17d
29
gitea_api.py
Normal file
29
gitea_api.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
TOKEN = os.getenv("GITEA_TOKEN")
|
||||||
|
|
||||||
|
if not TOKEN:
|
||||||
|
print("Ошибка: токен не найден. Создайте файл .env с GITEA_TOKEN=ваш_токен")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
headers = {"Authorization": f"token {TOKEN}"}
|
||||||
|
|
||||||
|
print("=" * 50)
|
||||||
|
print("Проверка подключения к Gitea API")
|
||||||
|
print("=" * 50)
|
||||||
|
response = requests.get("https://git.vyatsu.ru/api/v1/user", headers=headers)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
user_info = response.json()
|
||||||
|
print(f"Подключение успешно!")
|
||||||
|
print(f"Пользователь: {user_info.get('login')}")
|
||||||
|
print(f"Email: {user_info.get('email')}")
|
||||||
|
print(f"Полное имя: {user_info.get('full_name')}")
|
||||||
|
print(f"ID: {user_info.get('id')}")
|
||||||
|
else:
|
||||||
|
print(f"Ошибка: {response.status_code}")
|
||||||
|
print(response.text)
|
||||||
Loading…
Reference in New Issue
Block a user