#!/usr/bin/env python3
"""人生选择题 Web 服务器 - 端口 5180"""
import http.server
import socketserver
import os

PORT = 5180
DIR = os.path.dirname(os.path.abspath(__file__)) or "."

class Handler(http.server.SimpleHTTPRequestHandler):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, directory=DIR, **kwargs)

    def log_message(self, format, *args):
        pass  # 静默日志

os.chdir(DIR)
socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer(("", PORT), Handler) as httpd:
    print(f"🚀 人生选择题已启动: http://localhost:{PORT}/life.html")
    httpd.serve_forever()
