返回提交历史
Modified
g4f/gui/server/website.py
+2
-21
XFEstudio/gpt4free
refactor: simplify render logic and remove unused routes in Website class
0500e81c
代码差异
1 个文件
+2
-21
@@ -26,12 +26,7 @@ def render(filename = "home", download_url: str = GITHUB_URL):
26
26
if not path.startswith(base_dir + os.sep) and path != base_dir:
27
27
return redirect('/')
28
28
if os.path.exists(path):
29
if download_url == GITHUB_URL:
30
with open(path, 'r', encoding='utf-8') as f:
31
html = f.read()
32
is_temp = True
33
else:
34
return send_from_directory(os.path.dirname(path), os.path.basename(path))
29
return send_from_directory(os.path.dirname(path), os.path.basename(path))
35
30
try:
36
31
latest_version = version.utils.latest_version
37
32
except VersionNotFoundError:
@@ -129,14 +124,6 @@ class Website:
129
124
'function': self._dist,
130
125
'methods': ['GET']
131
126
},
132
'/gh/<path:name>': {
133
'function': self._gh,
134
'methods': ['GET']
135
},
136
'/npm/<path:name>': {
137
'function': self._npm,
138
'methods': ['GET']
139
},
140
127
'/playground/': {
141
128
'function': self._playground,
142
129
'methods': ['GET']
@@ -168,13 +155,7 @@ class Website:
168
155
return render(filename)
169
156
170
157
def _dist(self, name: str):
171
return send_from_directory(os.path.abspath(DIST_DIR), name)
172
173
def _gh(self, name):
174
return render(f"gh/{name}", JSDELIVR_URL)
175
176
def _npm(self, name):
177
return render(f"npm/{name}", JSDELIVR_URL)
158
return render(f"dist/{name}")
178
159
179
160
def _playground(self, filename: str = "index.html"):
180
161
PLAYGROUND_URL = "https://raw.githubusercontent.com/gpt4free/playground/refs/heads/main/"