carisackc commited on
Commit
914b2c0
·
1 Parent(s): 023278e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -8,6 +8,34 @@ import spacy
8
  from spacy import displacy
9
  import en_ner_bc5cdr_md
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  # Store the initial value of widgets in session state
12
  if "visibility" not in st.session_state:
13
  st.session_state.visibility = "visible"
 
8
  from spacy import displacy
9
  import en_ner_bc5cdr_md
10
 
11
+ from streamlit.components.v1 import html
12
+
13
+ def nav_page(page_name, timeout_secs=3):
14
+ nav_script = """
15
+ <script type="text/javascript">
16
+ function attempt_nav_page(page_name, start_time, timeout_secs) {
17
+ var links = window.parent.document.getElementsByTagName("a");
18
+ for (var i = 0; i < links.length; i++) {
19
+ if (links[i].href.toLowerCase().endsWith("/" + page_name.toLowerCase())) {
20
+ links[i].click();
21
+ return;
22
+ }
23
+ }
24
+ var elasped = new Date() - start_time;
25
+ if (elasped < timeout_secs * 1000) {
26
+ setTimeout(attempt_nav_page, 100, page_name, start_time, timeout_secs);
27
+ } else {
28
+ alert("Unable to navigate to page '" + page_name + "' after " + timeout_secs + " second(s).");
29
+ }
30
+ }
31
+ window.addEventListener("load", function() {
32
+ attempt_nav_page("%s", new Date(), %d);
33
+ });
34
+ </script>
35
+ """ % (page_name, timeout_secs)
36
+ html(nav_script)
37
+
38
+
39
  # Store the initial value of widgets in session state
40
  if "visibility" not in st.session_state:
41
  st.session_state.visibility = "visible"