test / app.py
wenjiao's picture
Update app.py
2a4b609
raw
history blame
1.49 kB
import gradio as gr
def initialize_interface():
# Create a JavaScript snippet to detect the browser language
detect_language_js = """
var language = window.navigator.userLanguage || window.navigator.language;
if (language === "zh-CN") {
document.getElementById("container").innerHTML = `
<div>
<label for="select_radio">你想使用哪种风格?</label>
<input type="radio" name="select_radio" value="卡通" checked> 卡通
<input type="radio" name="select_radio" value="风景"> 风景
<input type="radio" name="select_radio" value="肖像"> 肖像
<input type="radio" name="select_radio" value="生活"> 生活
</div>
`;
} else {
document.getElementById("container").innerHTML = `
<div>
<label for="select_detail">Providing your cartoon photos, scenes and decorations can be redesigned for your cartoon characters.</label>
<input type="text" id="select_detail" value="" style="width: 300px;">
</div>
`;
}
"""
# Create a Gradio interface with a WebView output to display the JavaScript-generated interface
interface = gr.Interface(fn=lambda: None, outputs="webview")
interface.launch(share=True, update_fn=detect_language_js, webview_size=(600, 200))
initialize_interface()