1MR commited on
Commit
caba13c
·
verified ·
1 Parent(s): 7d77c69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -83,7 +83,23 @@ chain_parallel = RunnableParallel({'chat_nutrition_prompt':chain1,
83
 
84
  @app.get("/")
85
  def read_root():
 
86
  return {"message": "This is My Nutrionguid App FAST"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  @app.post("/predictNUT")
89
  async def predict_image_and_nutrition(file: UploadFile = File(...)):
 
83
 
84
  @app.get("/")
85
  def read_root():
86
+ keep_alive()
87
  return {"message": "This is My Nutrionguid App FAST"}
88
+
89
+ def keep_alive(space_url="https://1mr-apigmail.hf.space/ping", interval_hours=5):
90
+ while True:
91
+ try:
92
+ print(f"🔄 Pinging {space_url} at {datetime.now()}")
93
+ response = requests.get(space_url)
94
+
95
+ if response.status_code == 200:
96
+ print("")
97
+ else:
98
+ print("")
99
+ except Exception as e:
100
+ print("")
101
+
102
+ time.sleep(interval_hours * 3600)
103
 
104
  @app.post("/predictNUT")
105
  async def predict_image_and_nutrition(file: UploadFile = File(...)):