XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Update website.py

ae5d7a19
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +11 -3
Modified g4f/constants.py +1 -0
@@ -4,3 +4,4 @@ GITHUB_REPOSITORY = f"xtekky/{ORGANIZATION}"
4 4 STATIC_DOMAIN = f"g4f.dev"
5 5 STATIC_URL = f"https://{STATIC_DOMAIN}/"
6 6 DIST_DIR = f"./{STATIC_DOMAIN}/dist"
7 DOWNLOAD_URL = f"https://raw.githubusercontent.com/{ORGANIZATION}/{STATIC_DOMAIN}/refs/heads/main/"
Modified g4f/gui/server/website.py +10 -3
@@ -7,7 +7,7 @@ from flask import send_from_directory, redirect
7 7 from ...image.copy_images import secure_filename
8 8 from ...cookies import get_cookies_dir
9 9 from ...errors import VersionNotFoundError
10 from ...constants import STATIC_URL, DIST_DIR
10 from ...constants import STATIC_URL, DOWNLOAD_URL, DIST_DIR
11 11 from ... import version
12 12
13 13 def redirect_home():
@@ -23,10 +23,17 @@ def render(filename = "chat"):
23 23 latest_version = version.utils.current_version
24 24 today = datetime.today().strftime('%Y-%m-%d')
25 25 cache_dir = os.path.join(get_cookies_dir(), ".gui_cache")
26 cache_file = os.path.join(cache_dir, f"{today}.{secure_filename(f'{filename}.{version.utils.current_version}-{latest_version}')}.html")
26 cache_file = os.path.join(cache_dir, f"{filename}.{today}.{secure_filename(f'{version.utils.current_version}-{latest_version}')}.html")
27 27 if not os.path.exists(cache_file):
28 28 os.makedirs(cache_dir, exist_ok=True)
29 html = requests.get(f"{STATIC_URL}{filename}.html").text
29 response = requests.get(f"{DOWNLOAD_URL}{filename}.html")
30 if not response.ok:
31 for root, _, files in os.walk(cache_dir):
32 for file in files:
33 if file.startswith(filename):
34 return send_from_directory(os.path.abspath(root), file)
35 break
36 html = response.text
30 37 html = html.replace("../dist/", f"dist/")
31 38 html = html.replace("\"dist/", f"\"{STATIC_URL}dist/")
32 39 with open(cache_file, 'w', encoding='utf-8') as f: