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 = """
Welcome to the Odoo deployment Space. This lightweight API ensures the health and deployment status of the Odoo application environment.
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"}
Purpose: Documents all available API endpoints. Exposes this interactive documentation.
Purpose: Returns the application and Odoo version details.
Response Example:
{"version": "19.0", "sdk": "docker"}
Purpose: Lists simulated or available Odoo modules.
Response Example:
["base", "web", "crm", "website", "ecommerce", "inventory", "project"]
Purpose: Returns OS, platform, and python execution environment info.
Response Example:
{"os": "Linux", "python_version": "3.12.x", "arch": "x86_64"}
Purpose: Simple ping-pong endpoint to verify responsiveness.
Response Example:
{"ping": "pong"}