Pc_server / status_server.py
THEZYZSTUDIO's picture
Rename status_server (1).py to status_server.py
4e371f3 verified
#!/usr/bin/env python3
"""
HTTP status server — required by Hugging Face Spaces.
HF expects a response on port 7860, otherwise it marks the Space as crashed.
This runs alongside the Minecraft server.
"""
import http.server
import socketserver
import threading
import os
PORT = 7860
HTML = """<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Minecraft Server — THEZYZSTUDIO</title>
<style>
body { background: #1a1a2e; color: #e0e0e0; font-family: monospace;
display: flex; align-items: center; justify-content: center;
height: 100vh; margin: 0; }
.box { text-align: center; border: 1px solid #00ff88;
padding: 2rem 3rem; border-radius: 8px; }
h1 { color: #00ff88; font-size: 2rem; margin-bottom: 0.5rem; }
p { color: #aaa; }
.port { color: #ffcc00; font-size: 1.2rem; }
</style>
</head>
<body>
<div class="box">
<h1>🎮 Minecraft Server</h1>
<p>THEZYZSTUDIO — The Z AI Agent</p>
<p>Server is running on</p>
<p class="port">TCP Port 25565</p>
<p style="font-size:0.8rem;margin-top:1rem;color:#666;">
Use playit.gg or ngrok to connect externally
</p>
</div>
</body>
</html>
"""
class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers()
self.wfile.write(HTML.encode())
def log_message(self, format, *args):
pass # suppress access logs
def run():
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"[HTTP] Status page running on port {PORT}", flush=True)
httpd.serve_forever()
if __name__ == "__main__":
t = threading.Thread(target=run, daemon=True)
t.start()
t.join()