import subprocess, os, time, urllib.request

os.chdir(r"C:\Users\25044\Desktop\Proj\天璇")

server = subprocess.Popen(
    [r"runtime\python\python.exe", "manage.py", "runserver", "127.0.0.1:8765", "--noreload"],
    stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
)

time.sleep(4)

try:
    urllib.request.urlopen("http://127.0.0.1:8765/", timeout=5)
    print("SERVER_UP")
except Exception as e:
    print("SERVER_DOWN:", e)
