Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,56 +1,60 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import requests
|
| 4 |
-
from io import StringIO
|
| 5 |
|
| 6 |
-
# Define
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
"Musnad_Ahmad_Ibn-Hanbal":
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
"
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
-
# Define function to read CSV file from GitHub
|
| 23 |
-
def read_csv_from_github(file_url):
|
| 24 |
-
response = requests.get(file_url)
|
| 25 |
-
if response.status_code == 200:
|
| 26 |
-
return pd.read_csv(StringIO(response.text), encoding='utf-8')
|
| 27 |
-
else:
|
| 28 |
-
return None
|
| 29 |
-
|
| 30 |
# Main Streamlit app
|
| 31 |
def main():
|
| 32 |
st.title("Hadith Viewer")
|
| 33 |
st.sidebar.title("Books")
|
| 34 |
-
selected_book = st.sidebar.selectbox("Select a Book", list(
|
| 35 |
|
| 36 |
-
|
| 37 |
-
selected_folder = [k for k, v in folders.items() if v == selected_book][0]
|
| 38 |
-
files = ["Not Mufassala", "Mufassala"]
|
| 39 |
-
mufassala_option = st.sidebar.radio("Select Mufassala Option", files)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
csv_df = read_csv_from_github(file_url)
|
| 45 |
|
| 46 |
st.sidebar.subheader("Description")
|
| 47 |
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.")
|
| 48 |
|
| 49 |
-
if csv_df is not None:
|
| 50 |
-
st.dataframe(csv_df)
|
| 51 |
-
else:
|
| 52 |
-
st.error("Error loading CSV file")
|
| 53 |
-
|
| 54 |
# Display image
|
| 55 |
image_url = "https://raw.githubusercontent.com/halimbahae/Hadith/main/Hadith_Books.jpg"
|
| 56 |
st.image(image_url, caption="Hadith Books", use_column_width=True)
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Define array of file paths for each book
|
| 4 |
+
book_files = {
|
| 5 |
+
"Maliks_Muwataa": [
|
| 6 |
+
"maliks_muwataa_ahadith.utf8.csv",
|
| 7 |
+
"maliks_muwataa_ahadith_mushakkala_mufassala.utf8.csv"
|
| 8 |
+
],
|
| 9 |
+
"Musnad_Ahmad_Ibn-Hanbal": [
|
| 10 |
+
"musnad_ahmad_ibn-hanbal_ahadith.utf8.csv",
|
| 11 |
+
"musnad_ahmad_ibn-hanbal_ahadith_mushakkala.utf8.csv"
|
| 12 |
+
],
|
| 13 |
+
"Sahih_Al-Bukhari": [
|
| 14 |
+
"sahih_al-bukhari_ahadith.utf8.csv",
|
| 15 |
+
"sahih_al-bukhari_ahadith_mushakkala_mufassala.utf8.csv"
|
| 16 |
+
],
|
| 17 |
+
"Sahih_Muslim": [
|
| 18 |
+
"sahih_muslim_ahadith.utf8.csv",
|
| 19 |
+
"sahih_muslim_ahadith_mushakkala_mufassala.utf8.csv"
|
| 20 |
+
],
|
| 21 |
+
"Sunan_Abu-Dawud": [
|
| 22 |
+
"sunan_abu-dawud_ahadith.utf8.csv",
|
| 23 |
+
"sunan_abu-dawud_ahadith_mushakkala_mufassala.utf8.csv"
|
| 24 |
+
],
|
| 25 |
+
"Sunan_Al-Darimi": [
|
| 26 |
+
"sunan_al-darimi_ahadith.utf8.csv",
|
| 27 |
+
"sunan_al-darimi_ahadith_mushakkala_mufassala.utf8.csv"
|
| 28 |
+
],
|
| 29 |
+
"Sunan_Al-Nasai": [
|
| 30 |
+
"sunan_al-nasai_ahadith.utf8.csv",
|
| 31 |
+
"sunan_al-nasai_ahadith_mushakkala_mufassala.utf8.csv"
|
| 32 |
+
],
|
| 33 |
+
"Sunan_Al-Tirmidhi": [
|
| 34 |
+
"sunan_al-tirmidhi_ahadith.utf8.csv",
|
| 35 |
+
"sunan_al-tirmidhi_ahadith_mushakkala_mufassala.utf8.csv"
|
| 36 |
+
],
|
| 37 |
+
"Sunan_Ibn-Maja": [
|
| 38 |
+
"sunan_ibn-maja_ahadith.utf8.csv",
|
| 39 |
+
"sunan_ibn-maja_ahadith_mushakkala_mufassala.utf8.csv"
|
| 40 |
+
]
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Main Streamlit app
|
| 44 |
def main():
|
| 45 |
st.title("Hadith Viewer")
|
| 46 |
st.sidebar.title("Books")
|
| 47 |
+
selected_book = st.sidebar.selectbox("Select a Book", list(book_files.keys()))
|
| 48 |
|
| 49 |
+
selected_files = book_files[selected_book]
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
st.sidebar.subheader("Files in Selected Book")
|
| 52 |
+
for file in selected_files:
|
| 53 |
+
st.sidebar.write(file)
|
|
|
|
| 54 |
|
| 55 |
st.sidebar.subheader("Description")
|
| 56 |
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.")
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Display image
|
| 59 |
image_url = "https://raw.githubusercontent.com/halimbahae/Hadith/main/Hadith_Books.jpg"
|
| 60 |
st.image(image_url, caption="Hadith Books", use_column_width=True)
|