Spaces:
Sleeping
Sleeping
File size: 859 Bytes
df11e0e 1e99350 df11e0e 1e99350 75e2f5d df11e0e 1e99350 75e2f5d df11e0e 1e99350 df11e0e a04c0e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
import requests
def get_list_quran_chapters() -> dict:
"""
Fetches the list of Quran chapters from the API.
"""
try:
list_of_chapters = requests.get("https://quranapi.pages.dev/api/surah.json")
list_of_chapters.raise_for_status() # Raise an exception for HTTP errors
return list_of_chapters.json()
except requests.exceptions.RequestException as e:
return {"error": f"Could not retrieve chapters: {e}"}
# Create the Gradio interface
demo = gr.Interface(
fn=get_list_quran_chapters,
inputs=None, # No user input; trigger only on button click
outputs=gr.JSON(),
title="List of Chapters from Quran",
description="Click the button below to retrieve the list of all Quran chapters."
)
# Launch the interface
if __name__ == "__main__":
demo.launch(mcp_server=True)
|