Update app.py
Browse files
app.py
CHANGED
@@ -159,7 +159,8 @@ function uploadImage(prompt, images, event, source, value) {
|
|
159 |
function onDemoLoad(){
|
160 |
let envInfo = getEnvInfo();
|
161 |
console.log(envInfo);
|
162 |
-
return
|
|
|
163 |
}
|
164 |
</script>
|
165 |
'''
|
@@ -243,9 +244,9 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
|
|
243 |
random_button = gr.Button("Surprise Me", scale=1, min_width=10)
|
244 |
run_button = gr.Button( "GO!", scale=1, min_width=20, variant="primary",icon="https://huggingface.co/spaces/nsfwalex/sd_card/resolve/main/hot.svg")
|
245 |
|
246 |
-
def on_demo_load(request: gr.Request
|
247 |
params = dict(request.query_params)
|
248 |
-
print("load_demo, url params", params, "
|
249 |
if params.get("e", "0") == "1":
|
250 |
#update the image
|
251 |
#bind events
|
@@ -256,6 +257,6 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
|
|
256 |
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")''')
|
257 |
run_button.click(generate, inputs=[prompt], outputs=[result], js=f'''(p)=>window.postMessageToParent(p,"process_started","demo_hf_{cfg.get("name")}_card", "click_go")''')
|
258 |
random_button.click(fn=lambda x:x, inputs=[prompt], outputs=[prompt], js='''(p)=>window.g(p)''')
|
259 |
-
demo.load(fn=on_demo_load, inputs=[
|
260 |
if __name__ == "__main__":
|
261 |
demo.queue().launch(show_api=False)
|
|
|
159 |
function onDemoLoad(){
|
160 |
let envInfo = getEnvInfo();
|
161 |
console.log(envInfo);
|
162 |
+
return;
|
163 |
+
//return envInfo["__domain"], envInfo["__iframe_domain"]
|
164 |
}
|
165 |
</script>
|
166 |
'''
|
|
|
244 |
random_button = gr.Button("Surprise Me", scale=1, min_width=10)
|
245 |
run_button = gr.Button( "GO!", scale=1, min_width=20, variant="primary",icon="https://huggingface.co/spaces/nsfwalex/sd_card/resolve/main/hot.svg")
|
246 |
|
247 |
+
def on_demo_load(request: gr.Request):
|
248 |
params = dict(request.query_params)
|
249 |
+
print("load_demo, url params", params, "image", default_image)#, "domain", domain, "iframe", iframe_domain)
|
250 |
if params.get("e", "0") == "1":
|
251 |
#update the image
|
252 |
#bind events
|
|
|
257 |
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")''')
|
258 |
run_button.click(generate, inputs=[prompt], outputs=[result], js=f'''(p)=>window.postMessageToParent(p,"process_started","demo_hf_{cfg.get("name")}_card", "click_go")''')
|
259 |
random_button.click(fn=lambda x:x, inputs=[prompt], outputs=[prompt], js='''(p)=>window.g(p)''')
|
260 |
+
demo.load(fn=on_demo_load, inputs=[], outputs=[result], js='''()=>onDemoLoad()''')
|
261 |
if __name__ == "__main__":
|
262 |
demo.queue().launch(show_api=False)
|