Download scripts/update_readme.py from ericbotti/chameleon: direct link, hf CLI and curl.
- Browser
- Download file 887 Bytes
-
https://huggingface.co/spaces/ericbotti/chameleon/resolve/main/scripts/update_readme.py
- Command line
-
hf download hf://spaces/ericbotti/chameleon/scripts/update_readme.py
-
curl -L -o update_readme.py https://huggingface.co/spaces/ericbotti/chameleon/resolve/main/scripts/update_readme.py
887 Bytes
| """ | |
| Script to update the README file with the metadata required by Hugging Face Spaces. | |
| """ | |
| # Get Streamlit Version | |
| requirements_path = "requirements.txt" | |
| with open(requirements_path, 'r', encoding='utf-16') as requirements: | |
| for line in requirements: | |
| if line.strip().startswith("streamlit=="): | |
| streamlit_version = line.strip().split('==')[1] | |
| break | |
| # Update README | |
| readme_path = "README.md" | |
| hf_space_metadata = f"""\ | |
| --- | |
| title: Chameleon | |
| emoji: 🦎 | |
| colorFrom: green | |
| colorTo: yellow | |
| sdk: streamlit | |
| sdk_version: {streamlit_version} | |
| app_file: src/app.py | |
| pinned: true | |
| --- | |
| """ | |
| # Open the README file | |
| with open(readme_path, 'r') as original_readme: | |
| data = original_readme.read() | |
| # Rewrite the README file, with metadata prepended | |
| with open(readme_path, 'w', encoding="utf-8") as modified_readme: | |
| modified_readme.write(hf_space_metadata + data) | |