Update main.py
Browse files
main.py
CHANGED
@@ -1,53 +0,0 @@
|
|
1 |
-
from fastapi import FastAPI, File, UploadFile
|
2 |
-
from fastapi.responses import StreamingResponse
|
3 |
-
from fastapi_utils.tasks import repeat_every
|
4 |
-
import os
|
5 |
-
import io
|
6 |
-
import requests
|
7 |
-
|
8 |
-
app = FastAPI()
|
9 |
-
|
10 |
-
|
11 |
-
@app.on_event("startup")
|
12 |
-
@repeat_every(seconds=60 * 12) # 1 hour
|
13 |
-
async def refresh_the_api():
|
14 |
-
|
15 |
-
url = "https://research-project-h4fb.onrender.com/refresh_api"
|
16 |
-
|
17 |
-
payload = {}
|
18 |
-
headers = {
|
19 |
-
'accept': 'application/json'
|
20 |
-
}
|
21 |
-
|
22 |
-
response = requests.request("POST", url, headers=headers, data=payload)
|
23 |
-
|
24 |
-
print(response.text)
|
25 |
-
return response.text
|
26 |
-
|
27 |
-
|
28 |
-
@app.get("/test")
|
29 |
-
async def read_root():
|
30 |
-
return {"message":"running"}
|
31 |
-
|
32 |
-
|
33 |
-
@app.get("/start_model_trigger")
|
34 |
-
async def model_trigger(page:int):
|
35 |
-
while True:
|
36 |
-
try:
|
37 |
-
page = str(page)
|
38 |
-
url = "https://api-ai-service.transexpress.lk/trigger_the_data_fecher?page="+page+"&paginate=10000"
|
39 |
-
print(url,page)
|
40 |
-
|
41 |
-
payload = {}
|
42 |
-
headers = {
|
43 |
-
'accept': 'application/json'
|
44 |
-
}
|
45 |
-
|
46 |
-
response = requests.request("GET", url, headers=headers, data=payload)
|
47 |
-
page = int(page)+1
|
48 |
-
print(response.text)
|
49 |
-
except:
|
50 |
-
break
|
51 |
-
return page
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|