Update Dockerfile, README, routes, main.py, add app.py and expose
Browse filesFiles changed (5)
- Dockerfile+4-3
- README.md+21
- app.pyAdded+10
- app/api/routes.py+9-1
- app/main.py+25-3
12345672 unmodified lines1011121314FROM python:3.12-slimENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1WORKDIR /app2 unmodified linesCOPY . .EXPOSE 8000CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]123456782 unmodified lines1112131415FROM python:3.12-slimENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1 \PORT=7860WORKDIR /app2 unmodified linesCOPY . .EXPOSE 7860CMD ["python", "app.py"]
154 unmodified lines155156157158159160154 unmodified lines---## WhatsApp Baileys BridgeFALZH uses the official Meta Cloud API for production messages. During early stages β while waiting for commercial approval β a **Baileys-based bridge** acts as the WhatsApp gateway.154 unmodified lines155156157158159160161162163164165166167168169170171172173174175176177178179180181154 unmodified lines---## Hugging Face SpacesThis repository is prepared to run as a Hugging Face Space using the top-level `app.py` entrypoint.### What to do in Hugging Face1. Create a new Space with the Python template.2. Connect this repository to the Space.3. Configure the required secrets in the Space settings if you want the full backend features enabled.4. Deploy.The Space will expose the FastAPI app on port `7860` and the app will respond at:- `/` β simple service overview- `/healthz` β health check- `/docs` β interactive API documentationIf the external services are not configured yet, the app still starts in a lightweight demo mode and serves the health endpoint.---## WhatsApp Baileys BridgeFALZH uses the official Meta Cloud API for production messages. During early stages β while waiting for commercial approval β a **Baileys-based bridge** acts as the WhatsApp gateway.
12345678910import os
import uvicorn
from main import app as falzh_app
if __name__ == "__main__": port = int(os.environ.get("PORT", "7860")) uvicorn.run(falzh_app, host="0.0.0.0", port=port, log_level="info")32 unmodified lines333435363738394032 unmodified linesrouter = APIRouter()@router.get("/healthz", response_model=HealthResponse)async def healthz(container: Annotated[ServiceContainer, Depends(get_container)]) -> HealthResponse:return HealthResponse(service=container.settings.app_name)32 unmodified lines3334353637383940414243444546474832 unmodified linesrouter = APIRouter()@router.get("/", include_in_schema=False)async def root() -> dict[str, str]:return {"service": "FALZH", "status": "ready", "docs": "/docs"}@router.get("/healthz", response_model=HealthResponse)async def healthz(request: Request) -> HealthResponse:container = getattr(request.app.state, "container", None)if container is None:return HealthResponse(service="FALZH (demo mode)")return HealthResponse(service=container.settings.app_name)
15 unmodified lines16171819202122232415 unmodified lines) -> FastAPI:@asynccontextmanagerasync def lifespan(app: FastAPI) -> AsyncIterator[None]:active_settings = settings or (container.settings if container else get_settings())configure_logging(active_settings.log_level)app.state.container = container or await ServiceContainer.from_settings(active_settings)yieldapp = FastAPI(title="FALZH API", version="0.1.0", lifespan=lifespan)15 unmodified lines1617181920212223242526272829303132333435363738394041424344454615 unmodified lines) -> FastAPI:@asynccontextmanagerasync def lifespan(app: FastAPI) -> AsyncIterator[None]:app.state.container = Noneapp.state.container_init_error = Noneif container is not None:active_settings = container.settingsapp.state.container = containerelse:try:active_settings = settings or get_settings()except Exception as exc: # pragma: no cover - defensive startup pathactive_settings = Noneapp.state.container_init_error = str(exc)if active_settings is not None:configure_logging(active_settings.log_level)else:configure_logging("INFO")if container is None and active_settings is not None:try:app.state.container = await ServiceContainer.from_settings(active_settings)except Exception as exc: # pragma: no cover - defensive startup pathapp.state.container = Noneapp.state.container_init_error = str(exc)yieldapp = FastAPI(title="FALZH API", version="0.1.0", lifespan=lifespan)
Dockerfile+4-3
README.md+21
app.pyAdded+10
app/api/routes.py+9-1
app/main.py+25-3