Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,10 +87,14 @@ chain_parallel = RunnableParallel({'chat_nutrition_prompt':chain1,
|
|
| 87 |
|
| 88 |
@app.get("/")
|
| 89 |
def read_root():
|
| 90 |
-
|
| 91 |
return {"message": "This is My Nutrionguid App FAST"}
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
while True:
|
| 95 |
try:
|
| 96 |
print(f"🔄 Pinging {space_url} at {datetime.now()}")
|
|
@@ -104,6 +108,7 @@ def keep_alive(space_url="https://1mb1-nutritionguide.hf.space/", interval_hours
|
|
| 104 |
print("")
|
| 105 |
|
| 106 |
time.sleep(interval_hours * 3600)
|
|
|
|
| 107 |
@app.post("/predictNUT")
|
| 108 |
async def predict_image_and_nutrition(file: UploadFile = File(...)):
|
| 109 |
try:
|
|
|
|
| 87 |
|
| 88 |
@app.get("/")
|
| 89 |
def read_root():
|
| 90 |
+
keep_alive()
|
| 91 |
return {"message": "This is My Nutrionguid App FAST"}
|
| 92 |
|
| 93 |
+
@app.get("/ping")
|
| 94 |
+
def ping():
|
| 95 |
+
return {"status": "alive"}
|
| 96 |
+
|
| 97 |
+
def keep_alive(space_url="https://1mb1-nutritionguide.hf.space/ping", interval_hours=5):
|
| 98 |
while True:
|
| 99 |
try:
|
| 100 |
print(f"🔄 Pinging {space_url} at {datetime.now()}")
|
|
|
|
| 108 |
print("")
|
| 109 |
|
| 110 |
time.sleep(interval_hours * 3600)
|
| 111 |
+
|
| 112 |
@app.post("/predictNUT")
|
| 113 |
async def predict_image_and_nutrition(file: UploadFile = File(...)):
|
| 114 |
try:
|