alessandro trinca tornidor commited on
Commit
5d533ea
1 Parent(s): a9078f6

feat: save/load the number_score_de and number_score_en components values within the local storage

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -14,6 +14,7 @@ def clear2():
14
 
15
 
16
  with gr.Blocks() as gradio_app:
 
17
  app_logger.info("start gradio app building...")
18
 
19
  project_root_folder = Path(PROJECT_ROOT_FOLDER)
@@ -169,6 +170,15 @@ with gr.Blocks() as gradio_app:
169
  outputs=[html_output],
170
  js=js.js_update_ipa_output,
171
  )
 
 
 
 
 
 
 
 
 
172
 
173
 
174
  if __name__ == "__main__":
 
14
 
15
 
16
  with gr.Blocks() as gradio_app:
17
+ local_storage = gr.BrowserState([0.0, 0.0])
18
  app_logger.info("start gradio app building...")
19
 
20
  project_root_folder = Path(PROJECT_ROOT_FOLDER)
 
170
  outputs=[html_output],
171
  js=js.js_update_ipa_output,
172
  )
173
+
174
+ @gradio_app.load(inputs=[local_storage], outputs=[number_score_de, number_score_en])
175
+ def load_from_local_storage(saved_values):
176
+ print("loading from local storage", saved_values)
177
+ return saved_values[0], saved_values[1]
178
+
179
+ @gr.on([number_score_de.change, number_score_en.change], inputs=[number_score_de, number_score_en], outputs=[local_storage])
180
+ def save_to_local_storage(score_de, score_en):
181
+ return [score_de, score_en]
182
 
183
 
184
  if __name__ == "__main__":