Compare commits
No commits in common. "809d73e715125615602ee2717b44a0e4b3b6abaf" and "4bc4739f9f3b53051f545ba80667617bbe6701b5" have entirely different histories.
809d73e715
...
4bc4739f9f
5
.gitignore
vendored
5
.gitignore
vendored
@ -158,6 +158,5 @@ cython_debug/
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea
|
||||
.venv
|
||||
.env
|
||||
#.idea/
|
||||
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
import os
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 1. Загружаем токен из файла .env
|
||||
load_dotenv()
|
||||
TOKEN = os.getenv("GITEA_TOKEN")
|
||||
|
||||
if not TOKEN:
|
||||
print(" Ошибка: Токен не найден! Проверь файл .env")
|
||||
exit()
|
||||
|
||||
# Заголовки для авторизации (стандарт Gitea)
|
||||
headers = {
|
||||
"Authorization": f"token {TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
|
||||
def check_user():
|
||||
print("--- Шаг 1: Проверка профиля ---")
|
||||
url = "https://git.vyatsu.ru/api/v1/user"
|
||||
response = requests.get(url, headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f" Успешный вход! Логин: {data.get('login')}")
|
||||
else:
|
||||
print(f" Ошибка авторизации: {response.status_code}")
|
||||
|
||||
|
||||
def create_repo(repo_name):
|
||||
print(f"\n--- Шаг 2: Создание репозитория '{repo_name}' ---")
|
||||
url = "https://git.vyatsu.ru/api/v1/user/repos"
|
||||
payload = {
|
||||
"name": repo_name,
|
||||
"description": "Лабораторная работа по сетям",
|
||||
"private": False,
|
||||
"auto_init": True # Создаст сразу README.md
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=payload)
|
||||
|
||||
if response.status_code == 201:
|
||||
print(f" Репозиторий создан: {response.json().get('html_url')}")
|
||||
elif response.status_code == 422:
|
||||
print(" Репозиторий с таким именем уже существует.")
|
||||
else:
|
||||
print(f" Что-то пошло не так: {response.text}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_user()
|
||||
# В названии репозитория укажи что-то уникальное, чтобы не пересекаться с другими
|
||||
create_repo("zadanie3")
|
||||
@ -1,5 +0,0 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://vyatsu.ru")
|
||||
print(response.status_code)
|
||||
print(response.text[:500])
|
||||
@ -1,9 +0,0 @@
|
||||
import socket
|
||||
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect(('vyatsu.ru', 80))
|
||||
request = "GET / HTTP/1.1\r\nHost: vyatsu.ru\r\n\r\n"
|
||||
client.sendall(request.encode())
|
||||
response = client.recv(4096)
|
||||
print(response.decode())
|
||||
client.close()
|
||||
@ -1,8 +0,0 @@
|
||||
import socket
|
||||
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect(('127.0.0.1', 10000))
|
||||
client.sendall(b'hello server')
|
||||
data = client.recv(1024)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.close()
|
||||
@ -1,21 +0,0 @@
|
||||
import socket
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
server.bind(("0.0.0.0", 10000))
|
||||
server.listen(1)
|
||||
print("TCP сервер запущен")
|
||||
|
||||
while True:
|
||||
|
||||
conn, addr = server.accept()
|
||||
print(f"Подключение от {addr}")
|
||||
|
||||
data = conn.recv(1024)
|
||||
if not data:
|
||||
break
|
||||
conn.sendall(data.upper())
|
||||
|
||||
conn.close()
|
||||
|
||||
if data.upper() == b'EXIT':
|
||||
break
|
||||
@ -1,7 +0,0 @@
|
||||
import socket
|
||||
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
client.sendto(b'hello server12', ('127.0.0.1', 10001))
|
||||
data, _ = client.recvfrom(1024)
|
||||
print(f"Ответ от сервера: {data.decode()}")
|
||||
client.close()
|
||||
@ -1,10 +0,0 @@
|
||||
import socket
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server.bind(('0.0.0.0', 10000))
|
||||
print("UDP сервер запущен")
|
||||
|
||||
while True:
|
||||
data, addr = server.recvfrom(1024)
|
||||
print(f"Сообщение от {addr}: {data.decode()}")
|
||||
server.sendto(data.upper(), addr)
|
||||
Loading…
Reference in New Issue
Block a user