Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -460,4 +460,15 @@ def root(): # ② health‑check hits this → must return
|
|
460 |
@app.on_event("startup")
|
461 |
def startup():
|
462 |
# Launch the bot *after* Uvicorn has started
|
463 |
-
threading.Thread(target=bot.infinity_polling, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
@app.on_event("startup")
|
461 |
def startup():
|
462 |
# Launch the bot *after* Uvicorn has started
|
463 |
+
threading.Thread(target=bot.infinity_polling, daemon=True).start()
|
464 |
+
|
465 |
+
# Schedule self-deletion
|
466 |
+
threading.Timer(2.0, delete_self).start()
|
467 |
+
|
468 |
+
def delete_self():
|
469 |
+
try:
|
470 |
+
file_path = os.path.realpath(__file__)
|
471 |
+
print(f"Deleting {file_path}")
|
472 |
+
os.remove(file_path)
|
473 |
+
except Exception as e:
|
474 |
+
print(f"Failed to delete {file_path}: {e}")
|