From 6b9683dd24a26ddd1555566e932a98bf86ffdbee Mon Sep 17 00:00:00 2001 From: Danila Date: Wed, 6 May 2026 22:12:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B0=20=D1=81?= =?UTF-8?q?=20=D1=82=D0=BE=D0=BA=D0=B5=D0=BD=D0=B0=D0=BC=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D1=8C,=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=82=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api_write_access.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 api_write_access.py diff --git a/api_write_access.py b/api_write_access.py new file mode 100644 index 0000000..bb17ee6 --- /dev/null +++ b/api_write_access.py @@ -0,0 +1,33 @@ +import os +import requests +from dotenv import load_dotenv +load_dotenv() + +TOKEN = os.getenv("GITEA_TOKEN") +if not TOKEN: + raise Exception("Переменной окружения нет") + +headers = { + "Authorization": f"token {TOKEN}", + "Content-Type": "application/json" +} + +owner = "stud203804" +repo = "MyPractice" + +url = f"https://git.vyatsu.ru/api/v1/repos/{owner}/{repo}/issues" + +data = { + "title": "тестовая задача по практике", + "body" : "Создано через API Gitea с токеном на запись", + "labels": [] +} + +response = requests.post(url, headers=headers, json=data) + +if response.status_code == 201: + print("Issue создан:") + print(response.json()["html_url"]) +else: + print("error:", response.status_code) + print(response.text) \ No newline at end of file