Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ else:
|
|
| 25 |
|
| 26 |
# --- 設定: 許可されたIPアドレスのリストを外部から取得する関数 ---
|
| 27 |
# SQLコマンドのエンコードは維持
|
| 28 |
-
API_URL = "https://www.ryhintl.com/dbjson/getjson?sqlcmd=select
|
| 29 |
|
| 30 |
def fetch_allowed_ips():
|
| 31 |
"""指定されたAPIエンドポイントから許可IPリストを動的に取得する。"""
|
|
@@ -50,6 +50,7 @@ def fetch_allowed_ips():
|
|
| 50 |
if not allowed_ips:
|
| 51 |
print("警告: 外部DBから有効なIPアドレスが取得されませんでした。")
|
| 52 |
|
|
|
|
| 53 |
return allowed_ips
|
| 54 |
|
| 55 |
except requests.exceptions.RequestException as e:
|
|
@@ -64,6 +65,7 @@ def fetch_allowed_ips():
|
|
| 64 |
|
| 65 |
# スクリプト実行時に許可IPリストを初期化
|
| 66 |
ALLOWED_IPS = fetch_allowed_ips()
|
|
|
|
| 67 |
|
| 68 |
# --- Cohere 処理関数 ---
|
| 69 |
def req_process(prompt: str):
|
|
@@ -111,6 +113,7 @@ def get_client_ip(request: gr.Request) -> tuple[str, gr.update, gr.update]:
|
|
| 111 |
# ALLOWED_IPSはグローバル変数として既に定義されている
|
| 112 |
if check_ip in ALLOWED_IPS:
|
| 113 |
# --- IPが許可されている場合 ---
|
|
|
|
| 114 |
|
| 115 |
if forwarded_for:
|
| 116 |
display_msg = f"✅ アクセス許可: IPアドレスが許可リストに含まれています。\nクライアントIP (X-Forwarded-For): {check_ip}\n直接ホストIP: {client_ip}"
|
|
|
|
| 25 |
|
| 26 |
# --- 設定: 許可されたIPアドレスのリストを外部から取得する関数 ---
|
| 27 |
# SQLコマンドのエンコードは維持
|
| 28 |
+
API_URL = "https://www.ryhintl.com/dbjson/getjson?sqlcmd=select * from allowed_ips"
|
| 29 |
|
| 30 |
def fetch_allowed_ips():
|
| 31 |
"""指定されたAPIエンドポイントから許可IPリストを動的に取得する。"""
|
|
|
|
| 50 |
if not allowed_ips:
|
| 51 |
print("警告: 外部DBから有効なIPアドレスが取得されませんでした。")
|
| 52 |
|
| 53 |
+
print("allowed:",allowed_ips)
|
| 54 |
return allowed_ips
|
| 55 |
|
| 56 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 65 |
|
| 66 |
# スクリプト実行時に許可IPリストを初期化
|
| 67 |
ALLOWED_IPS = fetch_allowed_ips()
|
| 68 |
+
print('ALLOWED_IPS:',ALLOWED_IPS)
|
| 69 |
|
| 70 |
# --- Cohere 処理関数 ---
|
| 71 |
def req_process(prompt: str):
|
|
|
|
| 113 |
# ALLOWED_IPSはグローバル変数として既に定義されている
|
| 114 |
if check_ip in ALLOWED_IPS:
|
| 115 |
# --- IPが許可されている場合 ---
|
| 116 |
+
print('checkip:',check_ip)
|
| 117 |
|
| 118 |
if forwarded_for:
|
| 119 |
display_msg = f"✅ アクセス許可: IPアドレスが許可リストに含まれています。\nクライアントIP (X-Forwarded-For): {check_ip}\n直接ホストIP: {client_ip}"
|