Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
|
4 |
# Define array of file paths for each book
|
5 |
book_files = {
|
6 |
"Maliks_Muwataa": [
|
@@ -40,8 +40,9 @@ book_files = {
|
|
40 |
"sunan_ibn-maja_ahadith_mushakkala_mufassala.utf8.csv"
|
41 |
]
|
42 |
}
|
43 |
-
|
44 |
def main():
|
|
|
45 |
st.sidebar.title("Navigation")
|
46 |
st.sidebar.subheader("Actions")
|
47 |
if st.sidebar.button("Home"):
|
@@ -50,19 +51,16 @@ def main():
|
|
50 |
selected_book = st.sidebar.selectbox("Select a Book", list(book_files.keys()))
|
51 |
selected_files = book_files[selected_book]
|
52 |
selected_file = st.sidebar.selectbox("Select a File", selected_files)
|
53 |
-
|
54 |
# Load CSV file immediately when selected from the list
|
55 |
file_url = f"https://raw.githubusercontent.com/halimbahae/Hadith/main/{selected_book}/{selected_file}"
|
56 |
csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
|
57 |
if csv_df is not None:
|
58 |
# Display dataframe with search
|
59 |
display_table(csv_df)
|
60 |
-
|
61 |
def display_home():
|
62 |
st.title("Hadith Viewer")
|
63 |
st.image("https://raw.githubusercontent.com/halimbahae/Hadith/main/Hadith_Books.jpg", caption="Hadith Books", use_column_width=True)
|
64 |
st.write("Welcome to the Hadith Viewer! This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left to view its contents.")
|
65 |
-
|
66 |
def display_table(csv_df):
|
67 |
font_size = st.slider("Adjust Font Size", min_value=10, max_value=30, value=20)
|
68 |
st.write("### Table View")
|
@@ -70,7 +68,5 @@ def display_table(csv_df):
|
|
70 |
filtered_df = csv_df[csv_df.apply(lambda row: row.astype(str).str.contains(search_query, case=False).any(), axis=1)]
|
71 |
styled_df = filtered_df.style.set_properties(**{'font-size': f'{font_size}px'})
|
72 |
st.dataframe(styled_df)
|
73 |
-
|
74 |
-
if __name__ == "__main__":
|
75 |
-
display_home()
|
76 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import requests
|
4 |
# Define array of file paths for each book
|
5 |
book_files = {
|
6 |
"Maliks_Muwataa": [
|
|
|
40 |
"sunan_ibn-maja_ahadith_mushakkala_mufassala.utf8.csv"
|
41 |
]
|
42 |
}
|
43 |
+
# Main Streamlit app
|
44 |
def main():
|
45 |
+
st.title("Hadith Viewer")
|
46 |
st.sidebar.title("Navigation")
|
47 |
st.sidebar.subheader("Actions")
|
48 |
if st.sidebar.button("Home"):
|
|
|
51 |
selected_book = st.sidebar.selectbox("Select a Book", list(book_files.keys()))
|
52 |
selected_files = book_files[selected_book]
|
53 |
selected_file = st.sidebar.selectbox("Select a File", selected_files)
|
|
|
54 |
# Load CSV file immediately when selected from the list
|
55 |
file_url = f"https://raw.githubusercontent.com/halimbahae/Hadith/main/{selected_book}/{selected_file}"
|
56 |
csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
|
57 |
if csv_df is not None:
|
58 |
# Display dataframe with search
|
59 |
display_table(csv_df)
|
|
|
60 |
def display_home():
|
61 |
st.title("Hadith Viewer")
|
62 |
st.image("https://raw.githubusercontent.com/halimbahae/Hadith/main/Hadith_Books.jpg", caption="Hadith Books", use_column_width=True)
|
63 |
st.write("Welcome to the Hadith Viewer! This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left to view its contents.")
|
|
|
64 |
def display_table(csv_df):
|
65 |
font_size = st.slider("Adjust Font Size", min_value=10, max_value=30, value=20)
|
66 |
st.write("### Table View")
|
|
|
68 |
filtered_df = csv_df[csv_df.apply(lambda row: row.astype(str).str.contains(search_query, case=False).any(), axis=1)]
|
69 |
styled_df = filtered_df.style.set_properties(**{'font-size': f'{font_size}px'})
|
70 |
st.dataframe(styled_df)
|
71 |
+
if **name** == "__main__":
|
|
|
|
|
72 |
main()
|