Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make_ JS parameter references JS file? #1989

Closed
tt0203 opened this issue Aug 10, 2022 · 5 comments
Closed

How to make_ JS parameter references JS file? #1989

tt0203 opened this issue Aug 10, 2022 · 5 comments

Comments

@tt0203
Copy link

tt0203 commented Aug 10, 2022

I see that the cases provided on the official website are only the cases where the arrow function defines variables and returns. However, how to implement a custom function by referencing an online JS file?

Just i have an online JS file:
https://huggingface.co/spaces/changxin/test/raw/main/statics/md5.js
How can I use the md5 function?

@tt0203
Copy link
Author

tt0203 commented Aug 10, 2022

@abidlabs
Copy link
Member

Hi @tt0203, would you be able to give us more context around this issue? What is your Gradio code, and what does this md5 function do?

@tt0203
Copy link
Author

tt0203 commented Aug 11, 2022

@abidlabs

Now,I just try to use the following code:

import gradio as gr
demo=gr.Blocks()
with demo:
with gr.Tabs():
with gr.TabItem("js"):
gr.Markdown("# js处理测试")
a=gr.Textbox(label='请输入需要js处理的字符串')
js_output=gr.Textbox(label="JS输出")
js_button=gr.Button("调用js引用")
js_button.click(None,a,js_output,_js='(x)=>md5(x);<script src="https://huggingface.co/spaces/changxin/test/raw/main/statics/md5.js"></script>')
demo.launch()

I Want to implement the reference of MD5 function in JS file,but it doesn't work.

@tt0203
Copy link
Author

tt0203 commented Aug 11, 2022

Hi@abidlabs

Now,I just try to use the following code:

import gradio as gr
demo=gr.Blocks()
with demo:
with gr.Tabs():
with gr.TabItem("js"):
gr.Markdown("# js处理测试")
a=gr.Textbox(label='请输入需要js处理的字符串')
js_output=gr.Textbox(label="JS输出")
js_button=gr.Button("调用js引用")
js_button.click(None,a,js_output,_js='(x)=>md5(x);<script src="https://huggingface.co/spaces/changxin/test/raw/main/statics/md5.js"></script>')

demo.launch()

I want to implement the reference of MD5 function in JS file,use md5 function to encrypt the gr.Textbox string,but it doesn't work.

@abidlabs
Copy link
Member

Hi @tt0203, as I responded to your other issue, I believe you cannot access external javascript files from inside your Gradio app. This may change in the future (please track #2137), but at this moment we do not support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants