File size: 2,654 Bytes
6f7c08e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Simple FastAPI server for Hugging Face Spaces
This keeps the space alive and provides a basic web interface
"""

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
import uvicorn
import os

app = FastAPI()

@app.get("/", response_class=HTMLResponse)
async def root():
    """Root endpoint that returns a simple HTML page"""
    return """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Telegram Server Manager Bot</title>
            <style>
                body {
                    font-family: Arial, sans-serif;
                    max-width: 800px;
                    margin: 50px auto;
                    padding: 20px;
                    background-color: #f5f5f5;
                }
                .container {
                    background-color: white;
                    padding: 30px;
                    border-radius: 10px;
                    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
                }
                h1 {
                    color: #333;
                }
                .status {
                    color: #28a745;
                    font-weight: bold;
                }
                .info {
                    background-color: #e7f3ff;
                    padding: 15px;
                    border-radius: 5px;
                    margin: 20px 0;
                }
            </style>
        </head>
        <body>
            <div class="container">
                <h1>🤖 Telegram Server Manager Bot</h1>
                <p class="status">✅ Bot is running!</p>
                <div class="info">
                    <h3>About this bot:</h3>
                    <p>This bot allows you to remotely manage your server using Telegram.</p>
                    <ul>
                        <li>Run commands via Telegram</li>
                        <li>Monitor server status</li>
                        <li>Check system resources</li>
                    </ul>
                    <p><strong>Start a chat with your bot on Telegram to use it!</strong></p>
                </div>
            </div>
        </body>
    </html>
    """

@app.get("/health")
async def health():
    """Health check endpoint"""
    return {"status": "healthy", "bot": "running"}

@app.get("/api/status")
async def status():
    """Status endpoint"""
    return {
        "status": "online",
        "service": "Telegram Server Manager Bot",
        "port": 7860
    }

if __name__ == "__main__":
    # Run on port 7860 for Hugging Face Spaces
    port = int(os.environ.get("PORT", 7860))
    uvicorn.run(app, host="0.0.0.0", port=port)