Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -702,11 +702,10 @@
|
|
702 |
import gradio as gr
|
703 |
import requests
|
704 |
|
705 |
-
#
|
706 |
-
def get_surah(
|
707 |
try:
|
708 |
-
|
709 |
-
url = f"https://api.alquran.cloud/v1/surah/{surah_input}/editions/quran-simple,en.asad"
|
710 |
response = requests.get(url)
|
711 |
response.raise_for_status()
|
712 |
data = response.json()
|
@@ -723,15 +722,46 @@ def get_surah(surah_input):
|
|
723 |
except Exception as e:
|
724 |
return f"β API Error: {e}", ""
|
725 |
|
726 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
727 |
gr.Interface(
|
728 |
-
fn=get_surah,
|
729 |
-
inputs=gr.
|
730 |
outputs=[
|
731 |
gr.Textbox(label="π Arabic Text", lines=15),
|
732 |
gr.Textbox(label="π English Translation", lines=15)
|
733 |
],
|
734 |
-
title="π Quran Surah Viewer",
|
735 |
-
description="
|
736 |
).launch()
|
737 |
|
|
|
702 |
import gradio as gr
|
703 |
import requests
|
704 |
|
705 |
+
# Get surah text by number
|
706 |
+
def get_surah(surah_number):
|
707 |
try:
|
708 |
+
url = f"https://api.alquran.cloud/v1/surah/{surah_number}/editions/quran-simple,en.asad"
|
|
|
709 |
response = requests.get(url)
|
710 |
response.raise_for_status()
|
711 |
data = response.json()
|
|
|
722 |
except Exception as e:
|
723 |
return f"β API Error: {e}", ""
|
724 |
|
725 |
+
# Surah List (1-114)
|
726 |
+
surah_names = [
|
727 |
+
"1 - Al-Fatiha", "2 - Al-Baqarah", "3 - Aal-E-Imran", "4 - An-Nisa", "5 - Al-Ma'idah",
|
728 |
+
"6 - Al-An'am", "7 - Al-A'raf", "8 - Al-Anfal", "9 - At-Tawbah", "10 - Yunus",
|
729 |
+
"11 - Hud", "12 - Yusuf", "13 - Ar-Ra'd", "14 - Ibrahim", "15 - Al-Hijr",
|
730 |
+
"16 - An-Nahl", "17 - Al-Isra", "18 - Al-Kahf", "19 - Maryam", "20 - Ta-Ha",
|
731 |
+
"21 - Al-Anbiya", "22 - Al-Hajj", "23 - Al-Mu'minun", "24 - An-Nur", "25 - Al-Furqan",
|
732 |
+
"26 - Ash-Shu'ara", "27 - An-Naml", "28 - Al-Qasas", "29 - Al-Ankabut", "30 - Ar-Rum",
|
733 |
+
"31 - Luqman", "32 - As-Sajda", "33 - Al-Ahzab", "34 - Saba", "35 - Fatir",
|
734 |
+
"36 - Ya-Sin", "37 - As-Saffat", "38 - Sad", "39 - Az-Zumar", "40 - Ghafir",
|
735 |
+
"41 - Fussilat", "42 - Ash-Shura", "43 - Az-Zukhruf", "44 - Ad-Dukhan", "45 - Al-Jathiya",
|
736 |
+
"46 - Al-Ahqaf", "47 - Muhammad", "48 - Al-Fath", "49 - Al-Hujurat", "50 - Qaf",
|
737 |
+
"51 - Adh-Dhariyat", "52 - At-Tur", "53 - An-Najm", "54 - Al-Qamar", "55 - Ar-Rahman",
|
738 |
+
"56 - Al-Waqi'a", "57 - Al-Hadid", "58 - Al-Mujadila", "59 - Al-Hashr", "60 - Al-Mumtahina",
|
739 |
+
"61 - As-Saff", "62 - Al-Jumua", "63 - Al-Munafiqun", "64 - At-Taghabun", "65 - At-Talaq",
|
740 |
+
"66 - At-Tahrim", "67 - Al-Mulk", "68 - Al-Qalam", "69 - Al-Haqqah", "70 - Al-Ma'arij",
|
741 |
+
"71 - Nuh", "72 - Al-Jinn", "73 - Al-Muzzammil", "74 - Al-Muddaththir", "75 - Al-Qiyama",
|
742 |
+
"76 - Al-Insan", "77 - Al-Mursalat", "78 - An-Naba", "79 - An-Nazi'at", "80 - Abasa",
|
743 |
+
"81 - At-Takwir", "82 - Al-Infitar", "83 - Al-Mutaffifin", "84 - Al-Inshiqaq", "85 - Al-Buruj",
|
744 |
+
"86 - At-Tariq", "87 - Al-Ala", "88 - Al-Ghashiyah", "89 - Al-Fajr", "90 - Al-Balad",
|
745 |
+
"91 - Ash-Shams", "92 - Al-Lail", "93 - Ad-Duhaa", "94 - Ash-Sharh", "95 - At-Tin",
|
746 |
+
"96 - Al-Alaq", "97 - Al-Qadr", "98 - Al-Bayyina", "99 - Az-Zalzala", "100 - Al-Adiyat",
|
747 |
+
"101 - Al-Qari'a", "102 - At-Takathur", "103 - Al-Asr", "104 - Al-Humaza", "105 - Al-Fil",
|
748 |
+
"106 - Quraish", "107 - Al-Ma'un", "108 - Al-Kawthar", "109 - Al-Kafiroon", "110 - An-Nasr",
|
749 |
+
"111 - Al-Masad", "112 - Al-Ikhlas", "113 - Al-Falaq", "114 - An-Nas"
|
750 |
+
]
|
751 |
+
|
752 |
+
# Extract surah number
|
753 |
+
def extract_number(surah_name):
|
754 |
+
return int(surah_name.split(" - ")[0])
|
755 |
+
|
756 |
+
# Gradio App
|
757 |
gr.Interface(
|
758 |
+
fn=lambda selected: get_surah(extract_number(selected)),
|
759 |
+
inputs=gr.Dropdown(choices=surah_names, label="π Select a Surah"),
|
760 |
outputs=[
|
761 |
gr.Textbox(label="π Arabic Text", lines=15),
|
762 |
gr.Textbox(label="π English Translation", lines=15)
|
763 |
],
|
764 |
+
title="π Quran Surah Viewer (Arabic + English)",
|
765 |
+
description="Select a Surah to see its Arabic text and English translation."
|
766 |
).launch()
|
767 |
|