fix bug with api and async proxy
Browse files- .gitignore +2 -1
- api/main.py +1 -1
- src/utils.py +8 -0
.gitignore
CHANGED
@@ -2,4 +2,5 @@ src/__pycache__/
|
|
2 |
api/__pycache__/
|
3 |
*.ipynb
|
4 |
*.csv
|
5 |
-
*.env
|
|
|
|
2 |
api/__pycache__/
|
3 |
*.ipynb
|
4 |
*.csv
|
5 |
+
*.env
|
6 |
+
src/extraction_normal.py
|
api/main.py
CHANGED
@@ -10,5 +10,5 @@ class Product(BaseModel):
|
|
10 |
@app.post("/product")
|
11 |
async def get_data(product: Product):
|
12 |
print(product)
|
13 |
-
data = await main(product)
|
14 |
return data
|
|
|
10 |
@app.post("/product")
|
11 |
async def get_data(product: Product):
|
12 |
print(product)
|
13 |
+
data = await main(product.product)
|
14 |
return data
|
src/utils.py
CHANGED
@@ -7,6 +7,14 @@ load_dotenv()
|
|
7 |
PROXY_PASSWORD = os.getenv("PROXY_PASSWORD")
|
8 |
PROXY_USER = os.getenv("PROXY_USER")
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def async_timer_decorator(func):
|
12 |
async def wrapper(*args, **kwargs):
|
|
|
7 |
PROXY_PASSWORD = os.getenv("PROXY_PASSWORD")
|
8 |
PROXY_USER = os.getenv("PROXY_USER")
|
9 |
|
10 |
+
def timer_decorator(func):
|
11 |
+
def wrapper(*args, **kwargs):
|
12 |
+
start_time = time.time()
|
13 |
+
result = func(*args, **kwargs)
|
14 |
+
end_time = time.time()
|
15 |
+
print(f"Function {func.__name__} took {end_time - start_time:.4f} seconds to execute")
|
16 |
+
return result
|
17 |
+
return wrapper
|
18 |
|
19 |
def async_timer_decorator(func):
|
20 |
async def wrapper(*args, **kwargs):
|