feat: add gitea api request
This commit is contained in:
parent
2c0055136b
commit
179f019121
34
gitea_api.py
34
gitea_api.py
@ -0,0 +1,34 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
token = os.getenv("GITEA_TOKEN")
|
||||||
|
|
||||||
|
if not token:
|
||||||
|
print("Ошибка: токен Gitea не найден. Проверьте файл .env")
|
||||||
|
return
|
||||||
|
|
||||||
|
url = "https://git.vyatsu.ru/api/v1/user"
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"token {token}"
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
|
||||||
|
print("Статус-код:", response.status_code)
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("Ответ API:")
|
||||||
|
print(response.json())
|
||||||
|
except ValueError:
|
||||||
|
print("Ответ сервера:")
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
Loading…
Reference in New Issue
Block a user