Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import requests
|
|
|
|
| 4 |
|
| 5 |
# Define the base URL for the raw GitHub content
|
| 6 |
base_url = "https://raw.githubusercontent.com/halimbahae/Hadith/main"
|
|
@@ -19,10 +20,10 @@ folders = {
|
|
| 19 |
}
|
| 20 |
|
| 21 |
# Define function to read CSV file from GitHub
|
| 22 |
-
def read_csv_from_github(
|
| 23 |
-
response = requests.get(
|
| 24 |
if response.status_code == 200:
|
| 25 |
-
return pd.read_csv(response.text, encoding='utf-8')
|
| 26 |
else:
|
| 27 |
return None
|
| 28 |
|
|
@@ -34,7 +35,8 @@ def main():
|
|
| 34 |
|
| 35 |
mufassala = st.sidebar.checkbox("Mufassala")
|
| 36 |
file_name = f"{selected_folder.lower()}_{'' if mufassala else 'not_'}mufassala.utf8.csv"
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
st.sidebar.subheader("Description")
|
| 40 |
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.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import requests
|
| 4 |
+
from io import StringIO
|
| 5 |
|
| 6 |
# Define the base URL for the raw GitHub content
|
| 7 |
base_url = "https://raw.githubusercontent.com/halimbahae/Hadith/main"
|
|
|
|
| 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 |
|
|
|
|
| 35 |
|
| 36 |
mufassala = st.sidebar.checkbox("Mufassala")
|
| 37 |
file_name = f"{selected_folder.lower()}_{'' if mufassala else 'not_'}mufassala.utf8.csv"
|
| 38 |
+
file_url = f"{base_url}/{selected_folder}/{file_name}"
|
| 39 |
+
csv_df = read_csv_from_github(file_url)
|
| 40 |
|
| 41 |
st.sidebar.subheader("Description")
|
| 42 |
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.")
|