Spaces:
Sleeping
Sleeping
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()) | |
async def your_continuous_function(): | |
global page | |
page+=1 | |
return "model trained with new page : "+str(page)+" data" | |
async def test_api(): | |
return "kpi_result" |