Update app.py
Browse files
app.py
CHANGED
@@ -81,7 +81,6 @@ js = '''
|
|
81 |
<script>
|
82 |
function getEnvInfo() {
|
83 |
const result = {};
|
84 |
-
|
85 |
// Get URL parameters
|
86 |
const urlParams = new URLSearchParams(window.location.search);
|
87 |
for (const [key, value] of urlParams) {
|
@@ -107,7 +106,7 @@ function getEnvInfo() {
|
|
107 |
return result;
|
108 |
}
|
109 |
window.g=function(p){
|
110 |
-
params = getUrlParamsAndDomain()
|
111 |
if (params["e"] != "1"){
|
112 |
return "";
|
113 |
}
|
@@ -158,7 +157,8 @@ function uploadImage(prompt, images, event, source, value) {
|
|
158 |
return ""
|
159 |
}
|
160 |
function onDemoLoad(){
|
161 |
-
let envInfo = getEnvInfo()
|
|
|
162 |
return envInfo["__domain"], envInfo["__iframe_domain"]
|
163 |
}
|
164 |
</script>
|
@@ -256,6 +256,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)
|
|
|
81 |
<script>
|
82 |
function getEnvInfo() {
|
83 |
const result = {};
|
|
|
84 |
// Get URL parameters
|
85 |
const urlParams = new URLSearchParams(window.location.search);
|
86 |
for (const [key, value] of urlParams) {
|
|
|
106 |
return result;
|
107 |
}
|
108 |
window.g=function(p){
|
109 |
+
params = getUrlParamsAndDomain();
|
110 |
if (params["e"] != "1"){
|
111 |
return "";
|
112 |
}
|
|
|
157 |
return ""
|
158 |
}
|
159 |
function onDemoLoad(){
|
160 |
+
let envInfo = getEnvInfo();
|
161 |
+
console.log(envInfo);
|
162 |
return envInfo["__domain"], envInfo["__iframe_domain"]
|
163 |
}
|
164 |
</script>
|
|
|
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=[], outputs=[result], js='''()=>onDemoLoad()''')
|
260 |
if __name__ == "__main__":
|
261 |
demo.queue().launch(show_api=False)
|