File size: 1,174 Bytes
496ed86
 
76b6132
496ed86
 
5b5e0bf
496ed86
 
 
 
5b5e0bf
76b6132
2143b44
5b5e0bf
 
 
 
 
 
 
 
 
 
 
 
496ed86
 
5b5e0bf
2143b44
5b5e0bf
2143b44
 
 
b7fbcc6
6242b18
2143b44
 
 
 
 
 
 
 
 
e686c88
6242b18
e686c88
b5e2f68
6242b18
2143b44
496ed86
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import StreamingResponse
from fastapi_utils.tasks import repeat_every
import os
import io
import requests

app = FastAPI()


@app.on_event("startup")
@repeat_every(seconds=60 * 12)  # 1 hour
async def refresh_the_api():
    
    url = "https://research-project-h4fb.onrender.com/refresh_api"
    
    payload = {}
    headers = {
      'accept': 'application/json'
    }
    
    response = requests.request("POST", url, headers=headers, data=payload)
    
    print(response.text)
    return response.text


@app.get("/test")
async def read_root():
    return {"message":"running"}
    

@app.get("/start_model_trigger")
async def model_trigger(page:int):
    while True:
        page = str(page)
        url = "https://api-ai-service.transexpress.lk/trigger_the_data_fecher?page="+page+"&paginate=10000"
        print(url,page)
        
        payload = {}
        headers = {
          'accept': 'application/json'
        }
        
        response = requests.request("GET", url, headers=headers, data=payload)
        page = int(page)+1
        print(response.text)
        break
    return page