Spaces:
Runtime error
Runtime error
Create bot/server/main.py
Browse files- bot/server/main.py +18 -0
bot/server/main.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from quart import Blueprint, jsonify
|
| 2 |
+
from bot.startup_log import uptime_s
|
| 3 |
+
from bot import TelegramBot
|
| 4 |
+
|
| 5 |
+
bp = Blueprint("main", __name__)
|
| 6 |
+
|
| 7 |
+
@bp.route("/")
|
| 8 |
+
async def home():
|
| 9 |
+
return "OK: talking bot + web server", 200
|
| 10 |
+
|
| 11 |
+
@bp.route("/health")
|
| 12 |
+
async def health():
|
| 13 |
+
# simple health + uptime + connected state
|
| 14 |
+
return jsonify({
|
| 15 |
+
"ok": True,
|
| 16 |
+
"uptime_s": uptime_s(),
|
| 17 |
+
"connected": bool(getattr(TelegramBot, "is_connected", False))
|
| 18 |
+
}), 200
|