nsfwalex commited on
Commit
7bd45d4
1 Parent(s): 482d3e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -18,6 +18,7 @@ import requests
18
  import torch
19
  from diffusers import DiffusionPipeline
20
  import importlib
 
21
 
22
  random.seed(time.time())
23
  MAX_SEED = 12211231
@@ -211,7 +212,8 @@ def generate(prompt, progress=gr.Progress(track_tqdm=True)):
211
 
212
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
213
  with gr.Row(equal_height=False):
214
- with gr.Group():
 
215
  result = gr.Gallery(
216
  label="Result", show_label=False, columns=1, rows=1, show_share_button=True,
217
  show_download_button=True,allow_preview=True,interactive=False, min_width=cfg.get("window_min_width", 340),height=360
@@ -230,6 +232,19 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
230
  run_button = gr.Button( "GO!", scale=1, min_width=20, variant="primary",icon="https://huggingface.co/spaces/nsfwalex/sd_card/resolve/main/hot.svg")
231
 
232
  def on_demo_load(request: gr.Request):
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  params = dict(request.query_params)
234
  default_image = cfg.get("cover_path", None)
235
 
@@ -247,7 +262,7 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
247
  default_image = None
248
  else:
249
  default_image = None
250
- print("load_demo, url params", params, "image", default_image)#, "domain", domain, "iframe", iframe_domain)
251
  if params.get("e", "0") == "1":
252
  #update the image
253
  #bind events
 
18
  import torch
19
  from diffusers import DiffusionPipeline
20
  import importlib
21
+ from urllib.parse import urlparse
22
 
23
  random.seed(time.time())
24
  MAX_SEED = 12211231
 
212
 
213
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
214
  with gr.Row(equal_height=False):
215
+ with gr.Group():
216
+
217
  result = gr.Gallery(
218
  label="Result", show_label=False, columns=1, rows=1, show_share_button=True,
219
  show_download_button=True,allow_preview=True,interactive=False, min_width=cfg.get("window_min_width", 340),height=360
 
232
  run_button = gr.Button( "GO!", scale=1, min_width=20, variant="primary",icon="https://huggingface.co/spaces/nsfwalex/sd_card/resolve/main/hot.svg")
233
 
234
  def on_demo_load(request: gr.Request):
235
+ current_domain = request.request.headers.get("Host", "")
236
+
237
+ # Get the potential iframe parent domain from the Referer header
238
+ referer = request.request.headers.get("Referer", "")
239
+ iframe_parent_domain = ""
240
+
241
+ if referer:
242
+ try:
243
+ parsed_referer = urlparse(referer)
244
+ iframe_parent_domain = parsed_referer.netloc
245
+ except:
246
+ iframe_parent_domain = "Unable to parse referer"
247
+
248
  params = dict(request.query_params)
249
  default_image = cfg.get("cover_path", None)
250
 
 
262
  default_image = None
263
  else:
264
  default_image = None
265
+ print("load_demo, url params", params, "image", default_image, "domain", current_domain, "iframe", iframe_parent_domain)
266
  if params.get("e", "0") == "1":
267
  #update the image
268
  #bind events