Spaces:
Infeksion
/
Sleeping

akhaliq HF Staff commited on
Commit
ba8977c
·
1 Parent(s): b277d84

Add standalone backend_deploy.py without Gradio dependencies

Browse files

Created backend_deploy.py as a standalone deployment utility that can be
used by the backend API without any Gradio dependencies. This module
provides clean deployment functions for HuggingFace Spaces.

Key features:
- deploy_to_huggingface_space(): Main deployment function supporting all
language types (HTML, Gradio, Streamlit, React, Transformers.js, ComfyUI)
- Automatic SDK detection and appropriate file structure generation
- Multi-file support (README, Dockerfile, requirements.txt, etc.)
- update_space_file(): Update individual files in existing spaces
- delete_space(): Delete spaces
- list_user_spaces(): List all user spaces

Code parsing utilities:
- parse_html_code(): Extract HTML from various formats
- parse_transformers_js_output(): Parse multi-file transformers.js output
- parse_python_requirements(): Extract requirements.txt
- parse_multi_file_python_output(): Parse Gradio/Streamlit multi-file apps
- is_streamlit_code() / is_gradio_code(): Code type detection
- detect_sdk_from_code(): Auto-detect appropriate HF Space SDK

File generators:
- create_space_readme(): Generate README.md with proper frontmatter
- create_dockerfile_for_streamlit(): Streamlit Dockerfile
- create_dockerfile_for_react(): React Dockerfile

Updated backend_api.py:
- Simplified /api/deploy endpoint to use backend_deploy module
- Reduced code duplication and improved maintainability
- Better error handling with user-friendly messages

Updated Dockerfile:
- Added COPY for backend_deploy.py

This completes the backend modularization, making deployment logic
reusable and maintainable without heavy UI dependencies.

3 files changed +538 -122
Files changed (3)
Dockerfile+1
backend_api.py+36-122
backend_deploy.pyAdded+501