Files
epub_bilingual_translator/archive/v0.13/scripts/test_conn.py
T

26 lines
806 B
Python

import asyncio
import os
import httpx
async def test_conn():
print(f"HTTP_PROXY: {os.environ.get('http_proxy')}")
print(f"HTTPS_PROXY: {os.environ.get('https_proxy')}")
print(f"ALL_PROXY: {os.environ.get('all_proxy')}")
url = "https://api.gpt.ge/v1/models"
headers = {"Authorization": f"Bearer {os.environ.get('V3_API_KEY')}"}
print(f"Connecting to {url}...")
try:
async with httpx.AsyncClient(timeout=10, follow_redirects=True) as client:
resp = await client.get(url, headers=headers)
print(f"Status: {resp.status_code}")
print(f"Headers: {resp.headers}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
from dotenv import load_dotenv
load_dotenv()
asyncio.run(test_conn())