Shivraj8615 commited on
Commit
03e7ddc
·
verified ·
1 Parent(s): ba35b4d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import time
3
+
4
+ # Predefined list of URLs
5
+ URL_LIST = ['https://eversense.forbesmarshall.com/dashboard/c4fd54f0-c1db-11ef-85d0-039aa56777b8?state=W3sicGFyYW1zIjp7fX1d',
6
+ 'https://eversense.forbesmarshall.com/dashboard/3e2088d0-305f-11ee-a0f4-61e9161020b8?state=W3sicGFyYW1zIjp7fX1d',
7
+ 'https://eversense.forbesmarshall.com/dashboard/28363120-2793-11ee-b1bd-d337304025bb?state=W3sicGFyYW1zIjp7fX1d',
8
+ 'https://eversense.forbesmarshall.com/dashboard/7a6d5b10-0378-11ee-82c9-cf44d27abef7?state=W3sicGFyYW1zIjp7fX1d',
9
+ 'https://eversense.forbesmarshall.com/dashboard/5bbfcf20-7ca1-11ee-8ff0-1ff70966bd0b?state=W3sicGFyYW1zIjp7fX1d',
10
+ 'https://eversense.forbesmarshall.com/dashboard/fce0ba90-a0d1-11ef-bb0b-1fc19820fcd6?state=W3sicGFyYW1zIjp7fX1d',
11
+ 'https://eversense.forbesmarshall.com/dashboard/c62a1620-c1d0-11ef-8fbe-512a6c27d06a?state=W3sicGFyYW1zIjp7fX1d',
12
+ 'https://eversense.forbesmarshall.com/dashboard/3dea3f20-5786-11ee-b3f1-c132cb361d73?state=W3sicGFyYW1zIjp7fX1d',
13
+ 'https://eversense.forbesmarshall.com/dashboard/a03dbd20-b2ff-11ef-946d-9f2f4424b7fb?state=W3sicGFyYW1zIjp7fX1d',
14
+ 'https://eversense.forbesmarshall.com/dashboard/77c97b40-2174-11ee-8c9f-7bdade8f0907?state=W3sicGFyYW1zIjp7fX1d',
15
+ 'https://eversense.forbesmarshall.com/dashboard/d1fea240-c1b2-11ef-85d0-039aa56777b8?state=W3sicGFyYW1zIjp7fX1d',
16
+ 'https://eversense.forbesmarshall.com/dashboard/46c34860-c1d6-11ef-85d0-039aa56777b8?state=W3sicGFyYW1zIjp7fX1d',
17
+ 'https://eversense.forbesmarshall.com/dashboard/70f29e80-b2e8-11ef-946d-9f2f4424b7fb?state=W3sicGFyYW1zIjp7fX1d',
18
+ 'https://eversense.forbesmarshall.com/dashboard/6ab1c430-b15b-11ef-a0e7-1fc19820fcd6?state=W3sicGFyYW1zIjp7fX1d'
19
+ ];
20
+
21
+ # Initialize session state
22
+ if 'running' not in st.session_state:
23
+ st.session_state.running = False
24
+ if 'current_index' not in st.session_state:
25
+ st.session_state.current_index = 0
26
+ if 'interval' not in st.session_state:
27
+ st.session_state.interval = 5 # Default interval in seconds
28
+
29
+ def toggle_running():
30
+ st.session_state.running = not st.session_state.running
31
+
32
+ def next_url():
33
+ st.session_state.current_index = (st.session_state.current_index + 1) % len(URL_LIST)
34
+
35
+ # UI Components
36
+ st.title("Rotating Website Viewer")
37
+ st.write("Cycles through predefined URLs at a set interval.")
38
+
39
+ # Interval selection
40
+ st.session_state.interval = st.slider("Select interval (seconds)", 10, 6000, st.session_state.interval)
41
+
42
+ # Start/Stop button
43
+ if st.button("Start" if not st.session_state.running else "Stop", on_click=toggle_running):
44
+ pass
45
+
46
+ # Display website in an iframe
47
+ current_url = URL_LIST[st.session_state.current_index]
48
+
49
+ st.markdown(f'<iframe src="{current_url}" width="100%" height="2000"></iframe>', unsafe_allow_html=True)
50
+
51
+ # Rotation logic
52
+ if st.session_state.running:
53
+ time.sleep(st.session_state.interval)
54
+ next_url()
55
+ st.rerun()