Spaces:
Build error
Build error
Download app.py from mayayahja/my-cloud-browser: direct link, hf CLI and curl.
- Browser
- Download file 889 Bytes
-
https://huggingface.co/spaces/mayayahja/my-cloud-browser/resolve/main/app.py
- Command line
-
hf download hf://spaces/mayayahja/my-cloud-browser/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mayayahja/my-cloud-browser/resolve/main/app.py
889 Bytes
| from fastapi import FastAPI | |
| import threading | |
| import time | |
| from browser_logic import start_browser_automation | |
| app = FastAPI() | |
| # Global variable to track bot status | |
| bot_status = {"status": "Starting up..."} | |
| def read_root(): | |
| return {"message": "Server is awake and running 24/7!"} | |
| def read_status(): | |
| return bot_status | |
| def background_task(): | |
| global bot_status | |
| bot_status["status"] = "Browser automation running..." | |
| try: | |
| # Start the headless browser loop | |
| start_browser_automation() | |
| except Exception as e: | |
| bot_status["status"] = f"Error occurred: {str(e)}" | |
| print(f"Browser task crashed: {e}") | |
| # Start the browser automation in a separate thread when the server starts | |
| def startup_event(): | |
| thread = threading.Thread(target=background_task, daemon=True) | |
| thread.start() | |