init commit

This commit is contained in:
2025-06-13 21:10:20 +09:00
commit d52c611afb
269 changed files with 37162 additions and 0 deletions

37
lottery/api_test.py Normal file
View File

@@ -0,0 +1,37 @@
import requests
import json
from dotenv import load_dotenv
import os
load_dotenv('.env')
def fetch_clients(api_url, api_key):
"""
Подключаемся к API с использованием заданного X-API-Key
"""
headers = {
"X-API-Key": api_key
}
try:
response = requests.get(api_url, headers=headers)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Ошибка при запросе к API: {e}")
return None
if __name__ == '__main__':
api_endpoint = os.getenv("API_URL")
api_key = os.getenv("API_KEY")
print(api_endpoint, api_key)
if not api_endpoint or not api_key:
print("Необходимо задать API_URL и API_KEY в .env файле.")
exit(1)
clients = fetch_clients(api_endpoint, api_key)
if clients is not None:
print(json.dumps(clients, indent=4, ensure_ascii=False))
else:
print("Не удалось получить данные с API.")