Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
@@ -9,69 +9,61 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
The Assembler Space itself runs as a Docker-based Space on Hugging Face, accessible via a public URL once deployed.
|
17 |
-
|
|
|
18 |
The API is hosted at:
|
19 |
https://<your-username>-assembler.hf.space/create-space
|
20 |
-
Replace
|
21 |
-
|
22 |
-
|
|
|
23 |
Creates a new Hugging Face Space based on the provided JSON payload.
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
Required
|
31 |
-
|
32 |
-
space_type
|
33 |
-
|
34 |
-
No
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
url
|
63 |
-
String
|
64 |
-
The URL of the newly created Space (e.g., https://huggingface.co/spaces/<username>/<space-name>).
|
65 |
-
note
|
66 |
-
String
|
67 |
-
Additional information (e.g., deployment time warning).
|
68 |
-
error
|
69 |
-
String
|
70 |
-
(Only in error responses) Description of what went wrong.
|
71 |
-
Example Requests and Responses
|
72 |
-
Example 1: Static Space
|
73 |
-
Request:
|
74 |
-
json
|
75 |
{
|
76 |
"space_type": "static",
|
77 |
"files": {
|
@@ -83,7 +75,7 @@ json
|
|
83 |
}
|
84 |
}
|
85 |
Response (200 OK):
|
86 |
-
|
87 |
{
|
88 |
"message": "New Space created",
|
89 |
"url": "https://huggingface.co/spaces/your-username/GeneratedSpace-abc123",
|
@@ -187,4 +179,7 @@ Limitations
|
|
187 |
Rate Limits: Hugging Face may restrict frequent Space creation. Check their API documentation for quotas.
|
188 |
File Size: Large files may fail to upload; keep contents reasonable (e.g., <1MB per file).
|
189 |
Error Handling: Basic validation is included, but complex syntax checking isn’t performed.
|
190 |
-
|
|
|
|
|
|
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
Here’s the Assembler Space API documentation rewritten in a Markdown code block, suitable for pasting into a Markdown file or passing to another LLM while preserving formatting.
|
13 |
+
markdown
|
14 |
+
# Assembler Space API Documentation
|
15 |
+
|
16 |
+
## Overview
|
17 |
+
The **Assembler Space** is a Hugging Face Space that acts as a factory for creating new Hugging Face Spaces dynamically. It exposes a Flask-based API that accepts JSON input containing code, files, parameters, and configuration details. Upon receiving a valid request, it creates a new Space repository on Hugging Face, populates it with the provided files, and triggers its deployment. The API supports multiple Space types (e.g., `gradio`, `static`, `docker`, `streamlit`) and multi-file submissions, making it versatile for generating a wide range of applications.
|
18 |
+
|
19 |
The Assembler Space itself runs as a Docker-based Space on Hugging Face, accessible via a public URL once deployed.
|
20 |
+
|
21 |
+
## Base URL
|
22 |
The API is hosted at:
|
23 |
https://<your-username>-assembler.hf.space/create-space
|
24 |
+
Replace `<your-username>` with the Hugging Face username hosting the Assembler Space. The exact URL will be provided once the Space is deployed.
|
25 |
+
|
26 |
+
## Endpoint
|
27 |
+
### `POST /create-space`
|
28 |
Creates a new Hugging Face Space based on the provided JSON payload.
|
29 |
+
|
30 |
+
#### Request Format
|
31 |
+
- **Method**: `POST`
|
32 |
+
- **Content-Type**: `application/json`
|
33 |
+
- **Body**: A JSON object with the following fields:
|
34 |
+
|
35 |
+
| Field | Type | Required | Description |
|
36 |
+
|--------------|----------|----------|-----------------------------------------------------------------------------|
|
37 |
+
| `space_type` | String | No | The type of Space to create. Options: `gradio`, `static`, `docker`, `streamlit`. Defaults to `gradio` if omitted. |
|
38 |
+
| `files` | Object | Yes | A dictionary where keys are filenames (e.g., `app.py`, `index.html`) and values are file contents as strings. |
|
39 |
+
| `parameters` | Object | No | A dictionary of key-value pairs to be injected into Python files as `PARAMS` or used by the generated Space’s code. |
|
40 |
+
|
41 |
+
#### Request Constraints
|
42 |
+
- At least one file must be provided in `files`.
|
43 |
+
- Filenames in `files` should include extensions (e.g., `.py`, `.html`, `.css`, `.txt`) to ensure correct handling.
|
44 |
+
- `space_type` must match one of the supported values, or the request will fail.
|
45 |
+
- File contents should be valid for the intended `space_type` (e.g., Python code for `gradio` or `docker`, HTML for `static`).
|
46 |
+
|
47 |
+
#### Response Format
|
48 |
+
- **Content-Type**: `application/json`
|
49 |
+
- **Status Codes**:
|
50 |
+
- `200 OK`: Space creation succeeded.
|
51 |
+
- `400 Bad Request`: Invalid JSON or missing/invalid fields.
|
52 |
+
- `500 Internal Server Error`: Unexpected error during Space creation.
|
53 |
+
- **Body**: A JSON object with the following fields:
|
54 |
+
|
55 |
+
| Field | Type | Description |
|
56 |
+
|-----------|--------|-----------------------------------------------------------------------------|
|
57 |
+
| `message` | String | A brief status message (e.g., `"New Space created"`). |
|
58 |
+
| `url` | String | The URL of the newly created Space (e.g., `https://huggingface.co/spaces/<username>/<space-name>`). |
|
59 |
+
| `note` | String | Additional information (e.g., deployment time warning). |
|
60 |
+
| `error` | String | (Only in error responses) Description of what went wrong. |
|
61 |
+
|
62 |
+
#### Example Requests and Responses
|
63 |
+
|
64 |
+
##### Example 1: Static Space
|
65 |
+
**Request:**
|
66 |
+
```json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
{
|
68 |
"space_type": "static",
|
69 |
"files": {
|
|
|
75 |
}
|
76 |
}
|
77 |
Response (200 OK):
|
78 |
+
|
79 |
{
|
80 |
"message": "New Space created",
|
81 |
"url": "https://huggingface.co/spaces/your-username/GeneratedSpace-abc123",
|
|
|
179 |
Rate Limits: Hugging Face may restrict frequent Space creation. Check their API documentation for quotas.
|
180 |
File Size: Large files may fail to upload; keep contents reasonable (e.g., <1MB per file).
|
181 |
Error Handling: Basic validation is included, but complex syntax checking isn’t performed.
|
182 |
+
|
183 |
+
---
|
184 |
+
|
185 |
+
This Markdown code block preserves the structure and formatting, making it easy to share or render in a Markdown viewer. You can copy this directly into a `.md` file or pass it to another LLM for further processing. Let me know if you need any adjustments!
|