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
1234456782 unmodified lines11121313141415FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 PYTHONUNBUFFERED=1 \ PORT=7860
WORKDIR /app
2 unmodified lines
COPY . .
EXPOSE 8000CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]EXPOSE 7860CMD ["python", "app.py"]154 unmodified lines155156157158159160161162163164165166167168169170171172173174175176177178179180181154 unmodified lines
---
## Hugging Face Spaces
This repository is prepared to run as a Hugging Face Space using the top-level `app.py` entrypoint.
### What to do in Hugging Face
1. 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 documentation
If the external services are not configured yet, the app still starts in a lightweight demo mode and serves the health endpoint.
---
## WhatsApp Baileys Bridge
FALZH 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 lines333435363738394041374243444546474832 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(container: Annotated[ServiceContainer, Depends(get_container)]) -> 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 lines1617181920211920212223242526272829303132333435363738394041424344454615 unmodified lines) -> FastAPI: @asynccontextmanager async 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) app.state.container = None app.state.container_init_error = None
if container is not None: active_settings = container.settings app.state.container = container else: try: active_settings = settings or get_settings() except Exception as exc: # pragma: no cover - defensive startup path active_settings = None app.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 path app.state.container = None app.state.container_init_error = str(exc)
yield
app = 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