Spaces:
Sleeping
Sleeping
| #!/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) |