Arafath10's picture
Update main.py
06a3097 verified
raw
history blame
950 Bytes
import asyncio
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import requests
import pandas as pd
import json
import httpx
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
global page
page = 1
# Declare the continuous function as an async function.
#async def your_continuous_function():
#await asyncio.sleep(60) # Adjust the sleep interval as needed
# Create a startup event.
#@app.on_event("startup")
#async def startup_event():
# Start the continuous function as a background task.
#asyncio.create_task(your_continuous_function())
@app.get("/trigger_the_data_fecher_every_60s")
async def your_continuous_function():
global page
page+=1
return "model trained with new page : "+page+" data"
@app.get("/test_api")
async def test_api():
return "kpi_result"