import os import platform from fastapi import FastAPI from fastapi.responses import HTMLResponse app = FastAPI( title="Odoo Space API", description="This is a lightweight API serving for Odoo deployment on Hugging Face Spaces.", version="19.0" ) @app.get("/health") def health(): """ Mandatory endpoint returning HTTP 200 when the app is ready. """ return {"status": "pass"} @app.get("/api-docs", response_class=HTMLResponse) def api_docs(): """ Mandatory endpoint that documents all available API endpoints. """ html_content = """ Odoo Space API Documentation

Odoo Space API Documentation

Welcome to the Odoo deployment Space. This lightweight API ensures the health and deployment status of the Odoo application environment.

Mandatory Endpoints

GET/health

Purpose: Returns HTTP 200 when the app is ready. Required for Hugging Face to transition the Space from starting to running.

Response Example:

{"status": "pass"}
GET/api-docs

Purpose: Documents all available API endpoints. Exposes this interactive documentation.

Functional Endpoints

GET/api/version

Purpose: Returns the application and Odoo version details.

Response Example:

{"version": "19.0", "sdk": "docker"}
GET/api/modules

Purpose: Lists simulated or available Odoo modules.

Response Example:

["base", "web", "crm", "website", "ecommerce", "inventory", "project"]
GET/api/sysinfo

Purpose: Returns OS, platform, and python execution environment info.

Response Example:

{"os": "Linux", "python_version": "3.12.x", "arch": "x86_64"}
GET/api/ping

Purpose: Simple ping-pong endpoint to verify responsiveness.

Response Example:

{"ping": "pong"}
""" return HTMLResponse(content=html_content, status_code=200) @app.get("/api/version") def version(): """ Returns application and Odoo version details. """ return {"version": "19.0", "sdk": "docker"} @app.get("/api/modules") def modules(): """ Lists Odoo modules in this repository. """ return ["base", "web", "crm", "website", "ecommerce", "inventory", "project"] @app.get("/api/sysinfo") def sysinfo(): """ Returns platform environment details. """ return { "system": platform.system(), "release": platform.release(), "version": platform.version(), "machine": platform.machine(), "python_version": platform.python_version() } @app.get("/api/ping") def ping(): """ Simple ping-pong endpoint to verify responsiveness. """ return {"ping": "pong"}