Spaces:
Sleeping
Sleeping
Upload 9 files
Browse files- .gitignore +5 -0
- Dockerfile +3 -0
- config_editor.py +72 -0
- start.bat +90 -0
- templates/login.html +1 -1
.gitignore
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
config.json
|
2 |
+
password.txt
|
3 |
+
venv/
|
4 |
+
__pycache__/
|
5 |
+
*.pyc
|
Dockerfile
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
FROM python:3.11-slim
|
2 |
|
|
|
|
|
|
|
3 |
WORKDIR /app
|
4 |
|
5 |
COPY requirements.txt .
|
|
|
1 |
FROM python:3.11-slim
|
2 |
|
3 |
+
# 设置用户为root
|
4 |
+
USER root
|
5 |
+
|
6 |
WORKDIR /app
|
7 |
|
8 |
COPY requirements.txt .
|
config_editor.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import hashlib
|
4 |
+
|
5 |
+
if __name__ == "__main__":
|
6 |
+
config = None
|
7 |
+
path = os.path.dirname(os.path.realpath(__file__))
|
8 |
+
os.chdir(path)
|
9 |
+
if os.path.exists("config.json"):
|
10 |
+
with open("config.json", "r") as f:
|
11 |
+
config = json.load(f)
|
12 |
+
try:
|
13 |
+
config["config"]
|
14 |
+
except KeyError:
|
15 |
+
config = None
|
16 |
+
if config is None:
|
17 |
+
print(f"配置文件不存在或为空,创建新配置...")
|
18 |
+
config = {"config": []}
|
19 |
+
print(f"输入会话ID: ")
|
20 |
+
user_data = {"conversation_id": input()}
|
21 |
+
print(f"输入cookies: ")
|
22 |
+
user_data["cookies"] = input()
|
23 |
+
config["config"].append(user_data)
|
24 |
+
|
25 |
+
again = True
|
26 |
+
while True:
|
27 |
+
if again:
|
28 |
+
num = len(config["config"])
|
29 |
+
print(f"\n当前有 {num} 个配置。")
|
30 |
+
print("----------")
|
31 |
+
print(f"1. 添加新配置")
|
32 |
+
print(f"2. 删除所有配置")
|
33 |
+
print(f"3. 设置密码")
|
34 |
+
print(f"4. 保存并退出")
|
35 |
+
choice = input()
|
36 |
+
|
37 |
+
if choice == "1":
|
38 |
+
print(f"输入会话ID: ")
|
39 |
+
user_data = {"conversation_id": input()}
|
40 |
+
print(f"输入cookies: ")
|
41 |
+
user_data["cookies"] = input()
|
42 |
+
config["config"].append(user_data)
|
43 |
+
print("\n成功添加配置!")
|
44 |
+
again = True
|
45 |
+
|
46 |
+
elif choice == "2":
|
47 |
+
print("确定要删除所有配置吗? (y/n)")
|
48 |
+
if input().lower() == 'y':
|
49 |
+
config["config"] = []
|
50 |
+
print("已删除所有配置")
|
51 |
+
again = True
|
52 |
+
|
53 |
+
elif choice == "3":
|
54 |
+
print(f"输入新密码(留空则删除密码): ")
|
55 |
+
password = input()
|
56 |
+
with open("password.txt", "w") as f:
|
57 |
+
if password != "":
|
58 |
+
f.write(hashlib.sha256(password.encode()).hexdigest())
|
59 |
+
print(f"密码已设置")
|
60 |
+
else:
|
61 |
+
f.write("")
|
62 |
+
print(f"密码已删除")
|
63 |
+
|
64 |
+
elif choice == "4":
|
65 |
+
with open("config.json", "w") as f:
|
66 |
+
json.dump(config, f, indent=4)
|
67 |
+
print("配置已保存")
|
68 |
+
break
|
69 |
+
|
70 |
+
else:
|
71 |
+
print(f"无效的选择")
|
72 |
+
again = False
|
start.bat
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@echo off
|
2 |
+
chcp 65001 > nul
|
3 |
+
|
4 |
+
echo checking python version...
|
5 |
+
python --version > nul 2>&1
|
6 |
+
if errorlevel 1 (
|
7 |
+
echo No python found. Please install python and add it to the PATH.
|
8 |
+
echo After installation, please restart the command prompt.
|
9 |
+
pause
|
10 |
+
exit /b
|
11 |
+
)
|
12 |
+
|
13 |
+
echo checking pip version...
|
14 |
+
pip --version > nul 2>&1
|
15 |
+
if errorlevel 1 (
|
16 |
+
echo No pip found. Please install pip.
|
17 |
+
echo After installation, please restart the command prompt.
|
18 |
+
pause
|
19 |
+
exit /b
|
20 |
+
)
|
21 |
+
|
22 |
+
echo checking venv module...
|
23 |
+
python -m venv venv
|
24 |
+
if errorlevel 1 (
|
25 |
+
echo No venv module found. Please upgrade your python to 3.3+.
|
26 |
+
pause
|
27 |
+
exit /b
|
28 |
+
)
|
29 |
+
|
30 |
+
echo activating virtual environment...
|
31 |
+
call venv\Scripts\activate.bat
|
32 |
+
if errorlevel 1 (
|
33 |
+
echo Failed to activate virtual environment, trying to install dependencies in global environment...
|
34 |
+
goto install_dependencies
|
35 |
+
)
|
36 |
+
|
37 |
+
echo virtual environment activated.
|
38 |
+
|
39 |
+
:install_dependencies
|
40 |
+
echo installing dependencies...
|
41 |
+
pip install -r requirements.txt
|
42 |
+
if errorlevel 1 (
|
43 |
+
echo Failed to install dependencies. Please check your network connection and try again.
|
44 |
+
pause
|
45 |
+
exit /b
|
46 |
+
)
|
47 |
+
|
48 |
+
echo dependencies installed.
|
49 |
+
|
50 |
+
:menu
|
51 |
+
cls
|
52 |
+
echo ================================
|
53 |
+
echo Abacus Chat Proxy
|
54 |
+
echo ================================
|
55 |
+
echo [0] 配置代理 (运行config_editor)
|
56 |
+
echo [1] 启动代理 (运行app.py)
|
57 |
+
echo ================================
|
58 |
+
set /p choice="请选择操作 (0/1): "
|
59 |
+
|
60 |
+
if "%choice%"=="0" (
|
61 |
+
echo 启动配置程序...
|
62 |
+
python config_editor.py
|
63 |
+
if errorlevel 1 (
|
64 |
+
echo 配置程序运行失败,请检查错误信息。
|
65 |
+
pause
|
66 |
+
exit /b
|
67 |
+
)
|
68 |
+
echo 配置完成,是否要立即启动代理?(Y/N)
|
69 |
+
set /p start_proxy="输入选择: "
|
70 |
+
if /i "%start_proxy%"=="Y" goto start_proxy
|
71 |
+
goto menu
|
72 |
+
)
|
73 |
+
|
74 |
+
if "%choice%"=="1" (
|
75 |
+
:start_proxy
|
76 |
+
echo 启动代理服务器...
|
77 |
+
python app.py
|
78 |
+
if errorlevel 1 (
|
79 |
+
echo 代理服务器启动失败,请检查错误信息。
|
80 |
+
pause
|
81 |
+
exit /b
|
82 |
+
)
|
83 |
+
echo 代理服务器正在运行: http://127.0.0.1:9876/
|
84 |
+
pause
|
85 |
+
exit /b
|
86 |
+
)
|
87 |
+
|
88 |
+
echo 无效的选择,请重试!
|
89 |
+
timeout /t 2 > nul
|
90 |
+
goto menu
|
templates/login.html
CHANGED
@@ -315,7 +315,7 @@
|
|
315 |
|
316 |
{% if space_url %}
|
317 |
<div class="space-info">
|
318 |
-
请访问 <a href="{{ space_url }}" target="_blank">{{ space_url }}</a> 登录查看使用情况
|
319 |
</div>
|
320 |
{% endif %}
|
321 |
|
|
|
315 |
|
316 |
{% if space_url %}
|
317 |
<div class="space-info">
|
318 |
+
请访问 <a href="{{ space_url }}/login" target="_blank">{{ space_url }}/login</a> 登录查看使用情况
|
319 |
</div>
|
320 |
{% endif %}
|
321 |
|