-
Notifications
You must be signed in to change notification settings - Fork 0
/
APP.py
36 lines (30 loc) · 1.12 KB
/
APP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import firebase_admin
from firebase_admin import credentials, db
import streamlit as st
# Initialize Firebase app
cred = credentials.Certificate("serviceAccountKey.json") # replace with your service account key
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://attendance-c065c-default-rtdb.firebaseio.com/'
})
# Function to retrieve data from Firebase
def get_data_from_firebase():
ref = db.reference('Students/') # replace with your data path
return ref.get()
# Main Streamlit app
def main():
st.title('Firebase Data Viewer')
# Retrieve data from Firebase
data = get_data_from_firebase()
# Display data in a table
if data:
st.write("### Students Data:")
st.write("| Key | Name | Present |")
st.write("| --- | ---- | ------- |")
for key, value in data.items():
name = value.get('name', 'N/A')
total_attendance = value.get('total_attendance', 'N/A')
st.write(f"| {key} | {name} | {total_attendance} |")
else:
st.write("No data available.")
if __name__ == "__main__":
main()