Spaces:
Paused
Paused
Update dummy_server.py
Browse files- dummy_server.py +13 -26
dummy_server.py
CHANGED
|
@@ -1,29 +1,16 @@
|
|
| 1 |
-
import
|
| 2 |
-
import os
|
| 3 |
-
from dummy_server import run_server
|
| 4 |
-
from bot import app
|
| 5 |
-
from worker import run_worker
|
| 6 |
-
from pyrogram import idle
|
| 7 |
|
| 8 |
-
async def
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
print("🤖 Starting Pyrogram Bot...")
|
| 15 |
-
await app.start()
|
| 16 |
-
|
| 17 |
-
# 3. Start the Sniper Workers
|
| 18 |
-
print("🚀 Firing up Sniper Workers...")
|
| 19 |
-
asyncio.create_task(run_worker())
|
| 20 |
|
| 21 |
-
|
| 22 |
-
await
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
# Pyrogram's app.run() handles the async event loop perfectly
|
| 29 |
-
app.run(main())
|
|
|
|
| 1 |
+
from aiohttp import web
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
async def handle_ping(request):
|
| 4 |
+
return web.Response(text="🟢 Sniper Bot is Online and Running!")
|
| 5 |
+
|
| 6 |
+
async def run_server():
|
| 7 |
+
app = web.Application()
|
| 8 |
+
app.router.add_get('/', handle_ping)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
runner = web.AppRunner(app)
|
| 11 |
+
await runner.setup()
|
| 12 |
|
| 13 |
+
# Hugging Face requires web servers to bind to 0.0.0.0 on port 7860
|
| 14 |
+
site = web.TCPSite(runner, '0.0.0.0', 7860)
|
| 15 |
+
await site.start()
|
| 16 |
+
print("🌐 Dummy web server started on port 7860")
|
|
|
|
|
|