import subprocess, time, urllib.request, sys, os os.chdir(r"C:\Users\25044\Desktop\Proj\天璇") p = subprocess.Popen([r"runtime\python\python.exe", "manage.py", "runserver", "127.0.0.1:8765", "--noreload"]) time.sleep(8) try: urllib.request.urlopen("http://127.0.0.1:8765/", timeout=5) print("SERVER_UP") except: print("SERVER_DOWN")