yaoqifa commited on
Commit
c4ea37d
·
verified ·
1 Parent(s): 1a4c02b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -8
app.py CHANGED
@@ -218,20 +218,49 @@ async def main_generate(api_key, model_name, prompt, ratio_selection, scale_sele
218
  # UI 构建
219
  # ==========================================
220
 
221
- # CSS: 彻底隐藏 Footer
222
  css = """
223
  #col-container {max-width: 900px; margin-left: auto; margin-right: auto;}
224
- footer { display: none !important; }
225
- .gradio-container footer { display: none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  """
227
 
228
- # JS: 页面加载时强制移除 Footer 元素
229
  js_remove_footer = """
230
  function() {
231
- const footer = document.querySelector("footer");
232
- if (footer) { footer.remove(); }
233
- const footerDiv = document.querySelector(".footer");
234
- if (footerDiv) { footerDiv.remove(); }
 
 
 
 
 
 
 
 
235
  }
236
  """
237
 
@@ -324,3 +353,7 @@ def health_check():
324
 
325
  # 挂载 Gradio 到根路径
326
  app = gr.mount_gradio_app(app, demo, path="/")
 
 
 
 
 
218
  # UI 构建
219
  # ==========================================
220
 
221
+ # CSS: 彻底隐藏 Footer (针对 HF 环境优化)
222
  css = """
223
  #col-container {max-width: 900px; margin-left: auto; margin-right: auto;}
224
+
225
+ /* 1. 隐藏标准 HTML footer 标签 */
226
+ footer {
227
+ display: none !important;
228
+ visibility: hidden !important;
229
+ height: 0 !important;
230
+ opacity: 0 !important;
231
+ pointer-events: none !important;
232
+ }
233
+
234
+ /* 2. 隐藏 Gradio 容器内的 footer 类 */
235
+ .gradio-container footer,
236
+ .gradio-container .footer {
237
+ display: none !important;
238
+ }
239
+
240
+ /* 3. 隐藏 API 链接和 Built with 标识 (常见类名) */
241
+ .built-with { display: none !important; }
242
+ .show-api { display: none !important; }
243
+ #settings { display: none !important; }
244
+
245
+ /* 4. 针对部分 HF 主题的特殊层级 */
246
+ div.footer { display: none !important; }
247
  """
248
 
249
+ # JS: 页面加载后再次强力移除 (双重保险)
250
  js_remove_footer = """
251
  function() {
252
+ function clean() {
253
+ const selectors = ["footer", ".footer", ".built-with", "#settings"];
254
+ selectors.forEach(s => {
255
+ const elements = document.querySelectorAll(s);
256
+ elements.forEach(el => el.remove());
257
+ });
258
+ }
259
+ // 立即执行
260
+ clean();
261
+ // 延迟执行 (防止 HF 延迟加载注入)
262
+ setTimeout(clean, 1000);
263
+ setTimeout(clean, 2000);
264
  }
265
  """
266
 
 
353
 
354
  # 挂载 Gradio 到根路径
355
  app = gr.mount_gradio_app(app, demo, path="/")
356
+
357
+ if __name__ == "__main__":
358
+ # 启动异步服务器
359
+ uvicorn.run(app, host="0.0.0.0", port=7860)