captain-awesome commited on
Commit
1e99350
·
verified ·
1 Parent(s): df11e0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,22 +1,26 @@
1
  import gradio as gr
2
- # from textblob import TextBlob
3
  import requests
4
 
5
- def get_list_quran_chapters(text: str) -> dict:
6
-
7
- list_of_chapters = requests.get("https://quranapi.pages.dev/api/surah.json")
8
-
9
-
 
 
 
 
 
10
 
11
  # Create the Gradio interface
12
  demo = gr.Interface(
13
- fn = get_list_quran_chapters,
14
- inputs=gr.Button(placeholder="Click..."),
15
  outputs=gr.JSON(),
16
- title="List of chapters from Quran",
17
- description="Get List of chapters from Quran"
18
  )
19
 
20
- # Launch the interface and MCP server
21
  if __name__ == "__main__":
22
- demo.launch(mcp_server=True)
 
1
  import gradio as gr
 
2
  import requests
3
 
4
+ def get_list_quran_chapters() -> dict:
5
+ """
6
+ Fetches the list of Quran chapters from the API.
7
+ """
8
+ try:
9
+ list_of_chapters = requests.get("https://quranapi.pages.dev/api/surah.json")
10
+ list_of_chapters.raise_for_status() # Raise an exception for HTTP errors
11
+ return list_of_chapters.json()
12
+ except requests.exceptions.RequestException as e:
13
+ return {"error": f"Could not retrieve chapters: {e}"}
14
 
15
  # Create the Gradio interface
16
  demo = gr.Interface(
17
+ fn=get_list_quran_chapters,
18
+ inputs=gr.Button("Get Chapters"), # Use a button to trigger the API call
19
  outputs=gr.JSON(),
20
+ title="List of Chapters from Quran",
21
+ description="Click the button to get a list of all chapters from the Quran."
22
  )
23
 
24
+ # Launch the interface
25
  if __name__ == "__main__":
26
+ demo.launch()