Spaces:
Running
Running
Update app.py
Browse files9 unmodified lines10111213141516171819202122232425269 unmodified lines@asynccontextmanagerasync def lifespan(app: FastAPI):# --- startup ---work()yield# --- shutdown ---app = FastAPI(lifespan=lifespan)@repeat_at(cron="* * * * *")def work():now_dtime = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')my_data.append(now_dtime)my_data.pop(0) # trim old values@app.get("/")def read_root():9 unmodified lines1011121314151617181920212223242526279 unmodified lines@asynccontextmanagerasync def lifespan(app: FastAPI):# --- startup ---work() # no await!yield# --- shutdown ---app = FastAPI(lifespan=lifespan)@repeat_at(cron="*/15 * * * *")def work():now_dtime = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')my_data.append(now_dtime)my_data.pop(0) # trim old valuesprint('-= work! =-')@app.get("/")def read_root():
app.py+3-2