Spaces:
Sleeping
Sleeping
Download launcher.py from kishankrish19/Vision: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/kishankrish19/Vision/resolve/main/launcher.py
- Command line
-
hf download hf://spaces/kishankrish19/Vision/launcher.py
-
curl -L -o launcher.py https://huggingface.co/spaces/kishankrish19/Vision/resolve/main/launcher.py
1.32 kB
| """Windows double-click entry point with browser opening and persistent server.""" | |
| import threading | |
| import urllib.request | |
| import webbrowser | |
| from app import create_app | |
| from waitress import serve | |
| URL='http://127.0.0.1:5000' | |
| def open_when_ready(): | |
| import time | |
| for _ in range(50): | |
| try: | |
| with urllib.request.urlopen(URL+'/login',timeout=1) as response: | |
| if response.status==200: | |
| webbrowser.open(URL) | |
| return | |
| except OSError: | |
| time.sleep(.2) | |
| if __name__=='__main__': | |
| try: | |
| with urllib.request.urlopen(URL+'/login',timeout=1) as response: | |
| existing=response.read().decode('utf-8') | |
| if 'Sign in · MOM' in existing: | |
| webbrowser.open(URL) | |
| print('The MOM app is already running. Opened it in your browser.') | |
| raise SystemExit(0) | |
| except OSError: | |
| pass | |
| app=create_app() | |
| print('MOM is running at '+URL+'\nKeep this window open while using the app. Press Ctrl+C to stop.',flush=True) | |
| threading.Thread(target=open_when_ready,daemon=True).start() | |
| try: | |
| serve(app,host='127.0.0.1',port=5000,threads=4) | |
| except OSError as error: | |
| print('Could not start the app. Port 5000 may be in use: '+str(error)) | |
| raise SystemExit(1) | |