Munwar92 commited on
Commit
5830366
·
verified ·
1 Parent(s): 9bb1fd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -9,16 +9,27 @@ from io import BytesIO
9
  from pydub import AudioSegment
10
  import os
11
 
 
 
12
  import httpx
13
 
 
14
  async def fetch_data(url):
15
  async with httpx.AsyncClient() as client:
16
  response = await client.get(url)
17
- return response.text # You can access the text after awaiting
18
 
19
- # In your main chatbot code, you need to await the result when calling the fetch_data function:
20
- response_text = await fetch_data("https://www.sbbusba.edu.pk/")
 
 
 
21
 
 
 
 
 
 
22
 
23
  # Initialize components
24
  translator = Translator()
 
9
  from pydub import AudioSegment
10
  import os
11
 
12
+ ##########
13
+ import asyncio
14
  import httpx
15
 
16
+ # Define an async function to fetch data
17
  async def fetch_data(url):
18
  async with httpx.AsyncClient() as client:
19
  response = await client.get(url)
20
+ return response.text # Return the response text
21
 
22
+ # Create another async function for the chatbot to run
23
+ async def main():
24
+ url = "https://www.sbbusba.edu.pk/"
25
+ response_text = await fetch_data(url) # Use await inside an async function
26
+ print(response_text) # Or process the response as needed
27
 
28
+ # Run the async function using asyncio.run()
29
+ if __name__ == "__main__":
30
+ asyncio.run(main()) # This is where the async function is actually executed
31
+
32
+ ###########
33
 
34
  # Initialize components
35
  translator = Translator()