Skip to content

Commit 00c247f

Browse files
ronvolutedjulien-cstevhliu
authored
docs(Spaces): Add details for custom Python Spaces (#87)
* docs(Spaces): Add details for custom Python Spaces * docs(Spaces): Clarify usage around custom Spaces * Update docs/hub/spaces.md Co-authored-by: Julien Chaumond <[email protected]> * Update docs/hub/spaces.md Co-authored-by: Julien Chaumond <[email protected]> * Update docs/hub/spaces.md Co-authored-by: Steven Liu <[email protected]> * Update docs/hub/spaces.md Co-authored-by: Steven Liu <[email protected]> Co-authored-by: Julien Chaumond <[email protected]> Co-authored-by: Steven Liu <[email protected]>
1 parent fda9e1d commit 00c247f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/hub/spaces.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,30 @@ jobs:
169169
170170
## Troubleshoot
171171
172+
### Streamlit
173+
172174
Issues may occur when you use an unsupported Streamlit version. The Streamlit version is not configured in the **requirements.txt** file but rather in the `YAML` settings through the `sdk_version` setting. Not all Streamlit versions are supported. Check that you are using a supported version of Streamlit. Refer to the [reference section](#reference) for more information about supported versions.
173175

176+
### Custom Python Spaces
177+
178+
While not an official workflow, you are able to run your own Python + interface stack in Spaces by selecting Gradio as your SDK and serving a frontend on port `7680`. See the [templates](https://huggingface.co/templates#spaces) for examples.
179+
180+
Spaces are served in iframes, which by default restrict links from opening in the parent page. The simplest solution is to open them in a new window:
181+
182+
```HTML
183+
<a href="https://hf.space" rel="noopener" target="_blank">Spaces</a>
184+
```
185+
186+
Usually, the height of Spaces is automatically adjusted when using the Gradio library interface. However, if you provide your own frontend in the Gradio SDK and the content height is larger than the viewport, you'll need to add an [iFrame Resizer script](https://cdnjs.com/libraries/iframe-resizer) so the content is scrollable in the iframe:
187+
188+
```HTML
189+
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.contentWindow.min.js"></script>
190+
```
191+
As an example, here is the same Space with and without the script:
192+
- https://huggingface.co/spaces/ronvolutional/http-server
193+
- https://huggingface.co/spaces/ronvolutional/iframe-test
194+
195+
174196
## Contact
175197

176198
Feel free to ask questions on the [forum](https://discuss.huggingface.co/) if it's suitable for the community.

0 commit comments

Comments
 (0)