Download app.py from alaskavix/README: direct link, hf CLI and curl.
- Browser
- Download file 693 Bytes
-
https://huggingface.co/spaces/alaskavix/README/resolve/main/app.py
- Command line
-
hf download hf://spaces/alaskavix/README/app.py
-
curl -L -o app.py https://huggingface.co/spaces/alaskavix/README/resolve/main/app.py
693 Bytes
| from fastapi import FastAPI | |
| from contextlib import asynccontextmanager | |
| import logging | |
| from bot import clientbot | |
| from subprocess import Popen | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| async def lifespan(app: FastAPI): | |
| logger.info("Starting up...") | |
| app.state.bot = await clientbot() | |
| # Set up auto-alive | |
| logger.info("Set up auto Alive...") | |
| Popen(["python", "alive.py"]) | |
| yield | |
| logger.info("Shutting down...") | |
| await app.state.bot.stop() | |
| app = FastAPI(lifespan=lifespan) | |
| async def root(): | |
| logger.info("Received root request") | |
| return {"message": "Hello, World!"} | |