pdf-4 / spaces_test.py
fokan's picture
Initial commit with static file serving and inline PDF viewing
623e14e
#!/usr/bin/env python3
"""
Test script to verify Hugging Face Spaces configuration
"""
import os
import sys
def check_huggingface_config():
"""Check if Hugging Face configuration is correct"""
print("Checking Hugging Face Spaces configuration...")
# Check if README.md exists and has the correct format
if not os.path.exists("README.md"):
print("❌ README.md file not found")
return False
with open("README.md", "r", encoding="utf-8") as f:
content = f.read()
# Check for required configuration section
if not content.startswith("---"):
print("❌ README.md missing configuration section")
return False
# Check for required fields
required_fields = ["title:", "emoji:", "colorFrom:", "colorTo:", "sdk:", "app_file:"]
for field in required_fields:
if field not in content:
print(f"❌ README.md missing required field: {field}")
return False
print("✅ README.md configuration section is correct")
# Check if Dockerfile exists
if not os.path.exists("Dockerfile"):
print("❌ Dockerfile not found")
return False
print("✅ Dockerfile found")
# Check if docker-compose.yml exists
if not os.path.exists("docker-compose.yml"):
print("❌ docker-compose.yml not found")
return False
print("✅ docker-compose.yml found")
# Check if src directory exists
if not os.path.exists("src"):
print("❌ src directory not found")
return False
print("✅ src directory found")
# Check if requirements.txt exists
if not os.path.exists("requirements.txt"):
print("❌ requirements.txt not found")
return False
print("✅ requirements.txt found")
print("\n🎉 All Hugging Face Spaces configuration checks passed!")
print("\nTo deploy to Hugging Face Spaces:")
print("1. Create a new Space at https://huggingface.co/spaces/new")
print("2. Select 'Docker' as the SDK")
print("3. Upload all files in this directory to your Space repository")
print("4. The Space will automatically build and deploy")
return True
if __name__ == "__main__":
success = check_huggingface_config()
sys.exit(0 if success else 1)