from huggingface_hub import HfApi import os def force_update_space(): """Force update the Hugging Face Space with latest content""" print("šŸš€ FORCE UPDATING HUGGING FACE SPACE") print("=" * 50) try: token = os.getenv("HF_TOKEN") api = HfApi(token=token) # Test login user_info = api.whoami() print(f"āœ… Logged in as: {user_info['name']}") print("\nšŸ“¤ Force uploading all files...") # Upload with force overwrite api.upload_folder( folder_path=".", repo_id="Cosmo125/Singtel_Bill_Scanner", repo_type="space", ignore_patterns=[ "*.pyc", "__pycache__/", ".venv/", "test_*.png", "test_*.jpg", "sample_*.jpg", "*.log", ".git/", "check_space.py", "force_update.py" ], commit_message="šŸ”„ Force update: Fix README and Streamlit app functionality", delete_patterns="*" # This will replace all files ) print("\nšŸŽ‰ SUCCESS! Force update completed!") print("šŸ”— Check your space: https://huggingface.co/spaces/Cosmo125/Singtel_Bill_Scanner") print("ā³ Allow 2-3 minutes for the app to rebuild") return True except Exception as e: print(f"āŒ Force update failed: {e}") return False if __name__ == "__main__": force_update_space()