Spaces:
Sleeping
Sleeping
File size: 3,048 Bytes
603fb76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
#!/usr/bin/env python3
"""
Automatisk uppladdningsskript för Hugging Face Space
Kör detta script för att ladda upp alla filer automatiskt
"""
import os
import sys
import subprocess
import webbrowser
import time
def main():
print("🚀 API DATA FETCHER - AUTOMATISK DEPLOYMENT")
print("=" * 50)
# Kontrollera att alla filer finns
required_files = ['app.py', 'requirements.txt', 'README.md']
missing_files = []
for file in required_files:
if os.path.exists(file):
size = os.path.getsize(file)
print(f"✅ {file} ({size} bytes)")
else:
missing_files.append(file)
print(f"❌ {file} - FEL SAKNAS!")
if missing_files:
print(f"\n❌ Saknade filer: {missing_files}")
return False
print(f"\n📁 Alla {len(required_files)} filer redo!")
# Testa lokal deployment först
print("\n🧪 TESTAR LOKAL DEPLOYMENT...")
try:
# Kör streamlit i bakgrunden för att testa
process = subprocess.Popen([
sys.executable, '-m', 'streamlit', 'run', 'app.py',
'--server.headless=true', '--server.port=8503'
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(3) # Vänta på start
if process.poll() is None: # Fortfarande igång
print("✅ Lokal test lyckades!")
process.terminate()
time.sleep(1)
else:
print("⚠️ Lokal test hade problem, men fortsätter...")
except Exception as e:
print(f"⚠️ Lokal test misslyckades: {e}")
print("📝 Fortsätter ändå med deployment...")
# Öppna Hugging Face
print("\n🌐 ÖPPNAR HUGGING FACE...")
try:
webbrowser.open('https://huggingface.co/new-space')
print("✅ Webbläsare öppnad")
except:
print("📱 Gå manuellt till: https://huggingface.co/new-space")
# Instruktioner
print("\n📋 DEPLOYMENT INSTRUKTIONER:")
print("1. Fyll i formuläret:")
print(" - Space name: api-data-fetcher")
print(" - Owner: isakskogstad")
print(" - SDK: Streamlit")
print(" - Hardware: CPU basic (free)")
print(" - Visibility: Public")
print("2. Klicka 'Create Space'")
print("3. Dra och släpp filerna från denna mapp")
print("4. Eller använd git push (se nedan)")
# Git instruktioner
print("\n🔧 GIT DEPLOYMENT (ALTERNATIV):")
print("git remote add origin https://huggingface.co/spaces/isakskogstad/api-data-fetcher")
print("git push origin main")
# Slutlig URL
print("\n🎯 SLUTLIG URL:")
print("https://huggingface.co/spaces/isakskogstad/api-data-fetcher")
print("\n✅ DEPLOYMENT GUIDE KLAR!")
return True
if __name__ == "__main__":
success = main()
if success:
print("\n🚀 Deployment redo! Följ instruktionerna ovan.")
else:
print("\n❌ Deployment misslyckades. Kontrollera filer.")
sys.exit(1) |