nsfwalex commited on
Commit
b8ed4b6
1 Parent(s): eb66ada

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -88,7 +88,21 @@ window.g=function(){
88
  prompt = generateSexyPrompt()
89
  console.log(prompt);
90
  return prompt
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  window.postMessageToParent = function(prompt, event, source, value) {
93
  // Construct the message object with the provided parameters
94
  console.log("post start",event, source, value);
@@ -187,7 +201,7 @@ else:
187
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
188
  with gr.Row(equal_height=False):
189
  with gr.Group():
190
- result = gr.Gallery(value=[cfg.get("cover_path","")],
191
  label="Result", show_label=False, columns=1, rows=1, show_share_button=True,
192
  show_download_button=True,allow_preview=True,interactive=False, min_width=cfg.get("window_min_width", 340),height=360
193
  )
@@ -207,6 +221,6 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
207
  random_button.click(fn=lambda x:x, inputs=[prompt], outputs=[prompt], js='''()=>window.g()''')
208
  run_button.click(generate, inputs=[prompt], outputs=[result], js=f'''(p)=>window.postMessageToParent(p,"process_started","demo_hf_{cfg.get("name")}_card", "click_go")''')
209
  result.change(fn=lambda x:x, inputs=[prompt,result], outputs=[], js=f'''(p,img)=>window.uploadImage(p, img,"process_finished","demo_hf_{cfg.get("name")}_card", "finish")''')
210
-
211
  if __name__ == "__main__":
212
  demo.queue().launch(show_api=False)
 
88
  prompt = generateSexyPrompt()
89
  console.log(prompt);
90
  return prompt
91
+ }
92
+ function checkDomain(img, str) {
93
+ // Get the current page's hostname (domain)
94
+ const currentDomain = window.location.hostname;
95
+
96
+ // Convert both the domain and the input string to lowercase for case-insensitive comparison
97
+ const lowerDomain = currentDomain.toLowerCase();
98
+ const lowerStr = str.toLowerCase();
99
+
100
+ // Check if the domain contains the string
101
+ if lowerDomain.includes(lowerStr){
102
+ return null;
103
+ }
104
+ return img;
105
+ }
106
  window.postMessageToParent = function(prompt, event, source, value) {
107
  // Construct the message object with the provided parameters
108
  console.log("post start",event, source, value);
 
201
  with gr.Blocks(css=css,head=js,fill_height=True) as demo:
202
  with gr.Row(equal_height=False):
203
  with gr.Group():
204
+ result = gr.Gallery(
205
  label="Result", show_label=False, columns=1, rows=1, show_share_button=True,
206
  show_download_button=True,allow_preview=True,interactive=False, min_width=cfg.get("window_min_width", 340),height=360
207
  )
 
221
  random_button.click(fn=lambda x:x, inputs=[prompt], outputs=[prompt], js='''()=>window.g()''')
222
  run_button.click(generate, inputs=[prompt], outputs=[result], js=f'''(p)=>window.postMessageToParent(p,"process_started","demo_hf_{cfg.get("name")}_card", "click_go")''')
223
  result.change(fn=lambda x:x, inputs=[prompt,result], outputs=[], js=f'''(p,img)=>window.uploadImage(p, img,"process_finished","demo_hf_{cfg.get("name")}_card", "finish")''')
224
+ demo.load(fn=lambda x:x, inputs=[default_image], outputs=[result], js='''(img)=>checkDomain(img, "huggingface")''')
225
  if __name__ == "__main__":
226
  demo.queue().launch(show_api=False)