Skip to content
Snippets Groups Projects
Commit c87e46e4 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Wait for confirmation that server is online before opening browser

parent 8b9da61a
No related branches found
No related tags found
No related merge requests found
import argparse
from multiprocessing import Process
import requests
import uvicorn
import webbrowser
......@@ -42,10 +43,18 @@ if __name__ == '__main__':
},
daemon=True,
)
server_process.start()
url = f'http://{args.host}:{int(args.port):04d}/status'
print(url)
server_process.start()
try:
resp = requests.get(url)
assert resp.status_code == 200
except Exception:
print('Error starting server')
server_process.terminate()
exit()
webbrowser.open(url, new=1, autoraise=True)
if args.debug:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment