Spaces:
Build error
Build error
Update app.py
Browse files
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 #
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 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()
|