Compare commits
4 Commits
f6e8f569ed
...
a1754feaf3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1754feaf3 | ||
|
|
8cad98daa1 | ||
|
|
1d18a464c7 | ||
|
|
cc934e987a |
29
skills/linggan/static-hosting/SKILL.md
Normal file
29
skills/linggan/static-hosting/SKILL.md
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
name: static-hosting
|
||||
description: Serve static HTML/CSS/JS/images from robot project directories via the built-in FastAPI static file server. Use when generating web pages, reports, or interactive content for a bot.
|
||||
---
|
||||
|
||||
# Static Hosting
|
||||
|
||||
Host static files (HTML, CSS, JS, images, fonts, etc.) under the bot's project directory and get public URLs.
|
||||
|
||||
## Usage
|
||||
|
||||
Write files to `/app/projects/robot/{ASSISTANT_ID}/`, then run the script to get the public URL:
|
||||
|
||||
```bash
|
||||
python3 {SKILL_DIR}/scripts/get_url.py <absolute_path>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
python3 {SKILL_DIR}/scripts/get_url.py /app/projects/robot/{ASSISTANT_ID}/index.html
|
||||
# => https://engine.aitravelmaster.com/robots/[bot-id]/index.html
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Inside HTML, use **relative paths** to reference other assets (e.g. `href="css/style.css"`)
|
||||
- `index.html` is auto-served at the directory URL
|
||||
- All files under `/robots/` are publicly accessible, no authentication
|
||||
25
skills/linggan/static-hosting/scripts/get_url.py
Normal file
25
skills/linggan/static-hosting/scripts/get_url.py
Normal file
@ -0,0 +1,25 @@
|
||||
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}")
|
||||
29
skills/support/static-hosting/SKILL.md
Normal file
29
skills/support/static-hosting/SKILL.md
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
name: static-hosting
|
||||
description: Serve static HTML/CSS/JS/images from robot project directories via the built-in FastAPI static file server. Use when generating web pages, reports, or interactive content for a bot.
|
||||
---
|
||||
|
||||
# Static Hosting
|
||||
|
||||
Host static files (HTML, CSS, JS, images, fonts, etc.) under `/workspace/` and get public URLs.
|
||||
|
||||
## Usage
|
||||
|
||||
Write files to `/workspace/`, then run the script to get the public URL:
|
||||
|
||||
```bash
|
||||
python3 {SKILL_DIR}/scripts/get_url.py <absolute_path>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
python3 {SKILL_DIR}/scripts/get_url.py /workspace/index.html
|
||||
# => https://api-dev.gptbase.ai/robot-assets/[bot-id]/index.html
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Inside HTML, use **relative paths** to reference other assets (e.g. `href="css/style.css"`)
|
||||
- `/workspace/index.html` is auto-served at the directory URL
|
||||
- All files under `/robot-assets/` are publicly accessible, no authentication
|
||||
25
skills/support/static-hosting/scripts/get_url.py
Normal file
25
skills/support/static-hosting/scripts/get_url.py
Normal file
@ -0,0 +1,25 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
BACKEND_HOST = os.getenv("BACKEND_HOST", "https://api-dev.gptbase.ai")
|
||||
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]} /workspace/index.html")
|
||||
sys.exit(1)
|
||||
|
||||
file_path = os.path.abspath(sys.argv[1])
|
||||
|
||||
workspace_root = "/workspace"
|
||||
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"{BACKEND_HOST.rstrip('/')}/robot-assets/{ASSISTANT_ID}"
|
||||
print(f"{base_url}{relative_path}")
|
||||
Loading…
Reference in New Issue
Block a user