Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -31,35 +31,9 @@ page = 1
|
|
31 |
@app.get("/trigger_the_data_fecher_every_60s")
|
32 |
async def your_continuous_function():
|
33 |
global page
|
34 |
-
|
35 |
-
|
36 |
-
# Initialize an empty DataFrame to store the combined data
|
37 |
-
combined_df = pd.DataFrame()
|
38 |
-
|
39 |
-
# Update the payload for each page
|
40 |
-
url = "https://dev3.api.curfox.parallaxtec.com/api/ml/order-list?sort=id&paginate=500&page="+str(page)
|
41 |
-
|
42 |
-
payload = {}
|
43 |
-
headers = {
|
44 |
-
'Accept': 'application/json',
|
45 |
-
'X-Tenant': 'royalexpress'
|
46 |
-
}
|
47 |
-
|
48 |
-
response = requests.request("GET", url, headers=headers, data=payload)
|
49 |
-
|
50 |
-
# Sample JSON response
|
51 |
-
json_response = response.json()
|
52 |
-
# Extracting 'data' for conversion
|
53 |
-
data = json_response['data']
|
54 |
-
|
55 |
-
df = pd.json_normalize(data)
|
56 |
-
|
57 |
-
# Concatenate the current page's DataFrame with the combined DataFrame
|
58 |
-
combined_df = pd.concat([combined_df, df], ignore_index=True)
|
59 |
-
|
60 |
-
data = combined_df[combined_df['status.name'].isin(['RETURN TO CLIENT', 'DELIVERED'])]
|
61 |
-
print("data collected from page : "+str(page))
|
62 |
page+=1
|
|
|
63 |
|
64 |
@app.get("/test_api")
|
65 |
async def test_api():
|
|
|
31 |
@app.get("/trigger_the_data_fecher_every_60s")
|
32 |
async def your_continuous_function():
|
33 |
global page
|
34 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
page+=1
|
36 |
+
return "model trained with new page : "+page+" data"
|
37 |
|
38 |
@app.get("/test_api")
|
39 |
async def test_api():
|