andreska commited on
Commit
ea67673
·
verified ·
1 Parent(s): e5153c2

Try fix javascript injection

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -7,12 +7,16 @@ class State:
7
 
8
  state = State()
9
 
 
 
 
 
10
  def update_values(context, question):
11
  state.context = context
12
  state.question = question
13
  return "I have stored the new values"
14
 
15
- with gr.Blocks() as demo:
16
  iface = gr.Interface(
17
  fn=update_values,
18
  inputs=["text", "text"],
@@ -27,10 +31,6 @@ with gr.Blocks() as demo:
27
  state.context = event.data
28
  iface.set_value(project_data, value=state.context)
29
  iface.set_value(output, value=state.context)
30
-
31
- demo.js_code("""
32
- window.addEventListener("message", on_message);
33
- """)
34
 
35
  iface.launch(
36
  server_name="0.0.0.0", # Allow external connections
 
7
 
8
  state = State()
9
 
10
+ js_code = """
11
+ window.addEventListener("message", on_message);
12
+ """)
13
+
14
  def update_values(context, question):
15
  state.context = context
16
  state.question = question
17
  return "I have stored the new values"
18
 
19
+ with gr.Blocks(js = js_code) as demo:
20
  iface = gr.Interface(
21
  fn=update_values,
22
  inputs=["text", "text"],
 
31
  state.context = event.data
32
  iface.set_value(project_data, value=state.context)
33
  iface.set_value(output, value=state.context)
 
 
 
 
34
 
35
  iface.launch(
36
  server_name="0.0.0.0", # Allow external connections