Moise Leance Sagbohan commited on
Commit
94d0dc9
·
1 Parent(s): e80fa16

Add application file

Browse files
Files changed (1) hide show
  1. app.py +134 -0
app.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pyrebase
3
+ from streamlit_option_menu import option_menu
4
+
5
+ import test_fin16
6
+
7
+
8
+ # APP PAGE SETTINGS
9
+
10
+ st.set_page_config(page_title="BAMSCAPE", page_icon=":bird:", layout='wide', initial_sidebar_state='auto')
11
+
12
+ st.markdown("""
13
+ <style>
14
+ .css-o18uir.e16nr0p33 {
15
+ margin-top: -75px;
16
+ }
17
+ </style>
18
+ """, unsafe_allow_html=True)
19
+
20
+ st.markdown(
21
+ """
22
+ <style>
23
+ div.stButton > button {background-color: #64B5F6;}
24
+ div.Controls_container__LTeAA > button {background: purple !important;}
25
+ .block-container {
26
+ padding-top: 2.5rem;
27
+ padding-bottom: 0rem;
28
+ padding-left: 5rem;
29
+ padding-right: 5rem;
30
+ }
31
+
32
+ iframe[title="streamlit_text_label.label_select"] .ant-btn {background: orange !important;}
33
+ iframe[title="streamlit_text_label.label_select"] .ant-btn-primary {background: orange !important;}
34
+ .ant-btn {background: violet !important;}
35
+ .ant-btn-primary {background: violet !important;}
36
+ button.ant-btn {background: violet !important;}
37
+ button.ant-btn-primary {background: violet !important;}
38
+ </style>
39
+ """, unsafe_allow_html=True
40
+ )
41
+
42
+ # MAIN PAGE HEADER
43
+
44
+ col1, col2 = st.columns((1, 10))
45
+ with col1:
46
+ st.image('bioacoustics_logo_large2.gif', width=90)
47
+ with col2:
48
+ st.header(':green[Brazilian Team] &mdash;' ' ' ':violet[_Bioacoustics_ :bird:]')
49
+
50
+ # FIREBASE KEYS AND AUTHENTICATION
51
+
52
+ firebaseConfig = {
53
+ 'apiKey': st.secrets["config_firebase"]['apiKey'],
54
+ 'authDomain': st.secrets["config_firebase"]['authDomain'],
55
+ 'projectId': st.secrets["config_firebase"]['projectId'],
56
+ 'databaseURL': st.secrets["config_firebase"]['databaseURL'],
57
+ 'storageBucket': st.secrets["config_firebase"]['storageBucket'],
58
+ 'messagingSenderId': st.secrets["config_firebase"]['messagingSenderId'],
59
+ 'appId': st.secrets["config_firebase"]['appId'],
60
+ 'measurementId': st.secrets["config_firebase"]['measurementId'],
61
+ }
62
+
63
+ fire = pyrebase.initialize_app(firebaseConfig)
64
+ auth = fire.auth()
65
+
66
+ # DATABASE
67
+
68
+ db = fire.database()
69
+ storage = fire.storage()
70
+
71
+ # MAIN APP
72
+
73
+ if 'useremail' not in st.session_state:
74
+ st.session_state.useremail = ''
75
+
76
+
77
+ def f():
78
+ try:
79
+ auth.sign_in_with_email_and_password(email, password)
80
+ st.session_state.signout = True
81
+ st.session_state.signedout = True
82
+ st.session_state.useremail = email
83
+ except:
84
+ st.text(' ')
85
+
86
+
87
+ def t():
88
+ st.session_state.signout = False
89
+ st.session_state.signedout = False
90
+
91
+
92
+ if 'signedout' not in st.session_state:
93
+ st.session_state['signedout'] = False
94
+
95
+ if 'signout' not in st.session_state:
96
+ st.session_state['signout'] = False
97
+
98
+ if not st.session_state['signedout']:
99
+ st.subheader(':orange[Please, log-in to access the interface]')
100
+ email = st.text_input(':blue[E-mail]', placeholder='Enter your e-mail')
101
+ password = st.text_input(':blue[Password]', placeholder='Enter your password', type='password')
102
+
103
+ if st.button('Login', on_click=f):
104
+ try:
105
+ auth.sign_in_with_email_and_password(email, password)
106
+ st.session_state.useremail = email
107
+ st.session_state.signout = True
108
+ st.session_state.signedout = True
109
+
110
+ except:
111
+ st.warning('Login failed, please enter a valid email/password')
112
+
113
+ if st.session_state.signout:
114
+ username = st.session_state.useremail
115
+ username = username.split('@')[0]
116
+ st.subheader(f':blue[Hello]' + ' ' + f':gray[{username}]' + ' ' + '👋🏻')
117
+ st.button('Sign out', on_click=t)
118
+ st.markdown('#####')
119
+ bio = option_menu(menu_title=None,
120
+ options=['Home', 'Database', 'Data analysis', 'Identification'],
121
+ icons=['house', 'volume-up', 'soundwave', 'layers'],
122
+ default_index=0,
123
+ styles={"nav-link": {"font-size": "17px", "text-align": "left", "margin": "0px"},
124
+ "nav-link-selected": {"background-color": "orange"}},
125
+ orientation='horizontal')
126
+
127
+ if bio == 'Identification':
128
+ annotator.iden()
129
+
130
+ st.markdown('#')
131
+
132
+
133
+
134
+