forked from gzzhongqi/geminicli2api
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_proxy.py
More file actions
31 lines (21 loc) · 840 Bytes
/
run_proxy.py
File metadata and controls
31 lines (21 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 1. 禁用安全警告(避免控制台全是警告信息)
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# 2. 备份原始的 request 方法
old_request = requests.Session.request
# 3. 重写 request 方法,强制设置 verify=False
def new_request(*args, **kwargs):
kwargs['verify'] = False
return old_request(*args, **kwargs)
requests.Session.request = new_request
import os
import uvicorn
import sys
sys.path.append(os.getcwd())
if __name__ == "__main__":
host = os.environ.get("HOST", "0.0.0.0")
port = int(os.environ.get("PORT", "8000"))
from src.main import app
print(f"Starting Proxy on port {port}...")
uvicorn.run(app, host=host, port=port)