Yang2001 commited on
Commit
92d22b4
·
1 Parent(s): f7a2756

fix: prevent page height growing infinitely and open redirect in new tab

Browse files
Files changed (2) hide show
  1. app.py +8 -6
  2. app_proxy.py +7 -6
app.py CHANGED
@@ -28,11 +28,12 @@ PROXY_HTML = """
28
  <title>Pixal3D | AI Image-to-3D</title>
29
  <style>
30
  * {{ margin: 0; padding: 0; box-sizing: border-box; }}
31
- body {{
32
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
33
  background: #0b0f1a;
34
  color: #f1f5f9;
35
- min-height: 100vh;
 
36
  display: flex;
37
  flex-direction: column;
38
  }}
@@ -164,7 +165,7 @@ def build_page():
164
  <p style="color:#f59e0b; margin-bottom:12px;">⚡ All users share a single GPU — requests are queued. Please be patient.</p>
165
  <p>You will be redirected automatically.</p>
166
  <p style="margin-top:16px;">
167
- <a href="{REMOTE_URL}" style="display:inline-block; padding:12px 32px; background:linear-gradient(135deg,#818cf8,#10b981); color:#fff; border-radius:8px; text-decoration:none; font-weight:600; font-size:15px;">
168
  Click here if not redirected
169
  </a>
170
  </p>
@@ -172,9 +173,9 @@ def build_page():
172
  </div>
173
  </div>
174
  <script>
175
- // Auto redirect after a short delay
176
  setTimeout(function() {{
177
- window.location.href = "{REMOTE_URL}";
178
  }}, 1500);
179
  </script>
180
  """
@@ -189,6 +190,7 @@ def build_page():
189
  <p>This Space acts as a proxy to a locally-deployed Pixal3D instance running on a dedicated GPU.</p>
190
  <p>To connect, set the <code>REMOTE_URL</code> secret in this Space's settings to your Gradio share link.</p>
191
  <p style="margin-top:24px; font-size:13px;">
 
192
  </p>
193
  </div>
194
  </div>
@@ -206,7 +208,7 @@ def build_page():
206
  # Use a simple Gradio Blocks app with HTML component
207
  with gr.Blocks(
208
  title="Pixal3D | AI Image-to-3D",
209
- css="footer {display:none !important;} .gradio-container {padding:0 !important; max-width:100% !important;} #proxy-frame {height:100vh; padding:0;}",
210
  theme=gr.themes.Base(),
211
  ) as demo:
212
  gr.HTML(build_page(), elem_id="proxy-frame")
 
28
  <title>Pixal3D | AI Image-to-3D</title>
29
  <style>
30
  * {{ margin: 0; padding: 0; box-sizing: border-box; }}
31
+ html, body {{
32
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
33
  background: #0b0f1a;
34
  color: #f1f5f9;
35
+ height: 100%;
36
+ overflow: hidden;
37
  display: flex;
38
  flex-direction: column;
39
  }}
 
165
  <p style="color:#f59e0b; margin-bottom:12px;">⚡ All users share a single GPU — requests are queued. Please be patient.</p>
166
  <p>You will be redirected automatically.</p>
167
  <p style="margin-top:16px;">
168
+ <a href="{REMOTE_URL}" target="_blank" rel="noopener noreferrer" style="display:inline-block; padding:12px 32px; background:linear-gradient(135deg,#818cf8,#10b981); color:#fff; border-radius:8px; text-decoration:none; font-weight:600; font-size:15px;">
169
  Click here if not redirected
170
  </a>
171
  </p>
 
173
  </div>
174
  </div>
175
  <script>
176
+ // Auto redirect in new tab after a short delay
177
  setTimeout(function() {{
178
+ window.open("{REMOTE_URL}", "_blank");
179
  }}, 1500);
180
  </script>
181
  """
 
190
  <p>This Space acts as a proxy to a locally-deployed Pixal3D instance running on a dedicated GPU.</p>
191
  <p>To connect, set the <code>REMOTE_URL</code> secret in this Space's settings to your Gradio share link.</p>
192
  <p style="margin-top:24px; font-size:13px;">
193
+ Example: <code>https://abcdef123456.gradio.live</code>
194
  </p>
195
  </div>
196
  </div>
 
208
  # Use a simple Gradio Blocks app with HTML component
209
  with gr.Blocks(
210
  title="Pixal3D | AI Image-to-3D",
211
+ css="footer {display:none !important;} .gradio-container {padding:0 !important; max-width:100% !important; height:100vh !important; overflow:hidden !important;} #proxy-frame {height:100%; max-height:100vh; padding:0; overflow:hidden;}",
212
  theme=gr.themes.Base(),
213
  ) as demo:
214
  gr.HTML(build_page(), elem_id="proxy-frame")
app_proxy.py CHANGED
@@ -28,11 +28,12 @@ PROXY_HTML = """
28
  <title>Pixal3D | AI Image-to-3D</title>
29
  <style>
30
  * {{ margin: 0; padding: 0; box-sizing: border-box; }}
31
- body {{
32
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
33
  background: #0b0f1a;
34
  color: #f1f5f9;
35
- min-height: 100vh;
 
36
  display: flex;
37
  flex-direction: column;
38
  }}
@@ -164,7 +165,7 @@ def build_page():
164
  <p style="color:#f59e0b; margin-bottom:12px;">⚡ All users share a single GPU — requests are queued. Please be patient.</p>
165
  <p>You will be redirected automatically.</p>
166
  <p style="margin-top:16px;">
167
- <a href="{REMOTE_URL}" style="display:inline-block; padding:12px 32px; background:linear-gradient(135deg,#818cf8,#10b981); color:#fff; border-radius:8px; text-decoration:none; font-weight:600; font-size:15px;">
168
  Click here if not redirected
169
  </a>
170
  </p>
@@ -172,9 +173,9 @@ def build_page():
172
  </div>
173
  </div>
174
  <script>
175
- // Auto redirect after a short delay
176
  setTimeout(function() {{
177
- window.location.href = "{REMOTE_URL}";
178
  }}, 1500);
179
  </script>
180
  """
@@ -207,7 +208,7 @@ def build_page():
207
  # Use a simple Gradio Blocks app with HTML component
208
  with gr.Blocks(
209
  title="Pixal3D | AI Image-to-3D",
210
- css="footer {display:none !important;} .gradio-container {padding:0 !important; max-width:100% !important;} #proxy-frame {height:100vh; padding:0;}",
211
  theme=gr.themes.Base(),
212
  ) as demo:
213
  gr.HTML(build_page(), elem_id="proxy-frame")
 
28
  <title>Pixal3D | AI Image-to-3D</title>
29
  <style>
30
  * {{ margin: 0; padding: 0; box-sizing: border-box; }}
31
+ html, body {{
32
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
33
  background: #0b0f1a;
34
  color: #f1f5f9;
35
+ height: 100%;
36
+ overflow: hidden;
37
  display: flex;
38
  flex-direction: column;
39
  }}
 
165
  <p style="color:#f59e0b; margin-bottom:12px;">⚡ All users share a single GPU — requests are queued. Please be patient.</p>
166
  <p>You will be redirected automatically.</p>
167
  <p style="margin-top:16px;">
168
+ <a href="{REMOTE_URL}" target="_blank" rel="noopener noreferrer" style="display:inline-block; padding:12px 32px; background:linear-gradient(135deg,#818cf8,#10b981); color:#fff; border-radius:8px; text-decoration:none; font-weight:600; font-size:15px;">
169
  Click here if not redirected
170
  </a>
171
  </p>
 
173
  </div>
174
  </div>
175
  <script>
176
+ // Auto redirect in new tab after a short delay
177
  setTimeout(function() {{
178
+ window.open("{REMOTE_URL}", "_blank");
179
  }}, 1500);
180
  </script>
181
  """
 
208
  # Use a simple Gradio Blocks app with HTML component
209
  with gr.Blocks(
210
  title="Pixal3D | AI Image-to-3D",
211
+ css="footer {display:none !important;} .gradio-container {padding:0 !important; max-width:100% !important; height:100vh !important; overflow:hidden !important;} #proxy-frame {height:100%; max-height:100vh; padding:0; overflow:hidden;}",
212
  theme=gr.themes.Base(),
213
  ) as demo:
214
  gr.HTML(build_page(), elem_id="proxy-frame")