Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,39 +27,24 @@ def read_csv_from_github(file_path):
|
|
27 |
else:
|
28 |
return None
|
29 |
|
30 |
-
# Define function to filter and paginate data
|
31 |
-
def filter_and_paginate_data(data, rows_per_page):
|
32 |
-
start_idx = (st.session_state.page_number - 1) * rows_per_page
|
33 |
-
end_idx = start_idx + rows_per_page
|
34 |
-
return data.iloc[start_idx:end_idx]
|
35 |
-
|
36 |
# Main Streamlit app
|
37 |
def main():
|
|
|
|
|
|
|
38 |
st.sidebar.title("Books")
|
39 |
selected_folder = st.sidebar.selectbox("Select a Book", list(folders.values()))
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
file_path = os.path.join(folder_name, selected_file)
|
46 |
-
if st.button("View File"):
|
47 |
-
csv_df = read_csv_from_github(file_path)
|
48 |
-
if csv_df is not None:
|
49 |
-
st.dataframe(csv_df)
|
50 |
-
else:
|
51 |
-
st.error("Error loading CSV file")
|
52 |
|
53 |
-
if
|
54 |
-
st.
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
if st.button("Apply Filters"):
|
60 |
-
if csv_df is not None:
|
61 |
-
filtered_data = filter_and_paginate_data(csv_df, rows_per_page)
|
62 |
-
st.write(filtered_data)
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
main()
|
|
|
27 |
else:
|
28 |
return None
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Main Streamlit app
|
31 |
def main():
|
32 |
+
st.title("Hadith Viewer")
|
33 |
+
st.image("https://github.com/halimbahae/Hadith/blob/main/Hadith_Books.jpg", caption="Hadith Books", use_column_width=True)
|
34 |
+
|
35 |
st.sidebar.title("Books")
|
36 |
selected_folder = st.sidebar.selectbox("Select a Book", list(folders.values()))
|
37 |
|
38 |
+
mufassala = st.sidebar.checkbox("Mufassala")
|
39 |
+
file_name = f"{selected_folder.replace(' ', '_').lower()}_ahadith_mushakkala_mufassala.utf8.csv" if mufassala else f"{selected_folder.replace(' ', '_').lower()}_ahadith.utf8.csv"
|
40 |
+
csv_df = read_csv_from_github(f"{selected_folder}/{file_name}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
if csv_df is not None:
|
43 |
+
st.sidebar.subheader("Description")
|
44 |
+
st.sidebar.write("This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left, and choose whether you want to view the 'Mufassala' version or not.")
|
45 |
+
st.dataframe(csv_df)
|
46 |
+
else:
|
47 |
+
st.error("Error loading CSV file")
|
|
|
|
|
|
|
|
|
48 |
|
49 |
if __name__ == "__main__":
|
50 |
main()
|