awacke1 commited on
Commit
8484605
·
1 Parent(s): 03e5d97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -60
app.py CHANGED
@@ -6,66 +6,6 @@ import pydeck as pdk
6
  import random
7
 
8
 
9
- def build_dataframe(rows_count=100):
10
- """
11
- Creates columns with random data.
12
- """
13
- data = {
14
- 'impressions': np.random.randint(low=111, high=10000, size=rows_count),
15
- 'clicks': np.random.randint(low=0, high=1000, size=rows_count),
16
- 'customer': random.choices(['ShirtsInc', 'ShoesCom'], k=rows_count)
17
- }
18
-
19
- df = pd.DataFrame(data)
20
- # add a date column and calculate the weekday of each row
21
- df['date'] = pd.date_range(start='1/1/2018', periods=rows_count)
22
-
23
- return df
24
-
25
-
26
- data_df = build_dataframe()
27
-
28
- query_params = st.experimental_get_query_params()
29
- # There is only one value for each parameter, retrieve the one at # # index 0
30
- username = query_params.get('username')[0]
31
- password = query_params.get('password')[0]
32
- view = query_params.get('view', None)[0]
33
-
34
- # Super basic (and not recommended) way to store the credentials
35
- # Just for illustrative purposes!
36
- credentials = {
37
- 'ShoesCom': 'shoespassword',
38
- 'ShirtsInc': 'shirtspassword'
39
- }
40
-
41
- logged_in = False
42
-
43
- # Check that the username exists in the "database" and that the provided password matches
44
- if username in credentials and credentials[username] == password:
45
- logged_in = True
46
-
47
- if not logged_in:
48
- # If credentials are invalid show a message and stop rendering the webapp
49
- st.warning('Invalid credentials')
50
- st.stop()
51
-
52
- available_views = ['report']
53
- if view not in available_views:
54
- # I don't know which view do you want. Beat it.
55
- st.warning('404 Error')
56
- st.stop()
57
- # The username exists and the password matches!
58
- # Also, the required view exists
59
- # Show the webapp
60
-
61
- st.title('Streamlit routing dashboard')
62
-
63
- # IMPORTANT: show only the data of the logged in customer
64
- st.dataframe(data_df[data_df['customer'] == username])
65
-
66
-
67
-
68
-
69
 
70
 
71
 
 
6
  import random
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11