Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -18,12 +18,21 @@ app.add_middleware(
|
|
18 |
allow_methods=["*"],
|
19 |
allow_headers=["*"],
|
20 |
)
|
21 |
-
|
22 |
|
23 |
@app.get("/get_scraped_data")
|
24 |
async def get_data(url: str):
|
|
|
|
|
25 |
try:
|
26 |
data = await Scraper.scrape(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
return data
|
28 |
except Exception as e:
|
29 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
18 |
allow_methods=["*"],
|
19 |
allow_headers=["*"],
|
20 |
)
|
21 |
+
import time
|
22 |
|
23 |
@app.get("/get_scraped_data")
|
24 |
async def get_data(url: str):
|
25 |
+
# Start time
|
26 |
+
start_time = time.time()
|
27 |
try:
|
28 |
data = await Scraper.scrape(url)
|
29 |
+
# End time
|
30 |
+
end_time = time.time()
|
31 |
+
|
32 |
+
# Calculate the elapsed time
|
33 |
+
elapsed_time = end_time - start_time
|
34 |
+
|
35 |
+
print(f"Time taken for the process: {elapsed_time:.2f} seconds")
|
36 |
return data
|
37 |
except Exception as e:
|
38 |
raise HTTPException(status_code=500, detail=str(e))
|