Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(...)):
|