26 lines
837 B
Python
26 lines
837 B
Python
import os
|
|
import sys
|
|
|
|
FASTAPI_URL = os.getenv("FASTAPI_URL", "https://engine.aitravelmaster.com")
|
|
ASSISTANT_ID = os.getenv("ASSISTANT_ID", "")
|
|
|
|
if not ASSISTANT_ID:
|
|
print("Error: ASSISTANT_ID environment variable is not set")
|
|
sys.exit(1)
|
|
|
|
if len(sys.argv) < 2:
|
|
print(f"Usage: python3 {sys.argv[0]} <file_path>")
|
|
print(f"Example: python3 {sys.argv[0]} /app/projects/robot/{ASSISTANT_ID}/index.html")
|
|
sys.exit(1)
|
|
|
|
file_path = os.path.abspath(sys.argv[1])
|
|
|
|
workspace_root = f"/app/projects/robot/{ASSISTANT_ID}"
|
|
if not file_path.startswith(workspace_root):
|
|
print(f"Error: path must be under {workspace_root}, got: {file_path}")
|
|
sys.exit(1)
|
|
|
|
relative_path = file_path[len(workspace_root):] # e.g. "/css/style.css"
|
|
base_url = f"{FASTAPI_URL.rstrip('/')}/robots/{ASSISTANT_ID}"
|
|
print(f"{base_url}{relative_path}")
|