Spaces:
tester343
/
Configuration error

jhh6576 commited on
Commit
21b8353
Β·
verified Β·
1 Parent(s): e22c38c

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +12 -6
app_enhanced.py CHANGED
@@ -850,8 +850,9 @@ def upload_file():
850
  f.save(comic_generator.video_path)
851
  success = comic_generator.generate_comic()
852
  if success:
853
- webbrowser.open("http://localhost:5000/comic")
854
- return "πŸŽ‰ Enhanced Comic Created Successfully!"
 
855
  else:
856
  return "❌ Comic generation failed"
857
  except Exception as e:
@@ -869,8 +870,7 @@ def handle_link():
869
  ydl.download([link])
870
  success = comic_generator.generate_comic()
871
  if success:
872
- webbrowser.open("http://localhost:5000/comic")
873
- return "πŸŽ‰ Enhanced Comic Created Successfully!"
874
  else:
875
  return "❌ Comic generation failed"
876
  except Exception as e:
@@ -925,6 +925,12 @@ def frame_file(filename):
925
 
926
  # --- FIX: Use __name__ == '__main__' for the execution block ---
927
  if __name__ == '__main__':
 
 
 
 
928
  print("πŸš€ Starting Enhanced Comic Generator...")
929
- print("🌐 Web interface available at: http://localhost:5000")
930
- app.run(debug=True, host='0.0.0.0', port=5000)
 
 
 
850
  f.save(comic_generator.video_path)
851
  success = comic_generator.generate_comic()
852
  if success:
853
+ # In a containerized environment like HF Spaces, webbrowser.open won't work.
854
+ # The user will access the app via the public URL provided by the Space.
855
+ return "πŸŽ‰ Enhanced Comic Created Successfully! Please refresh your browser and go to the /comic endpoint."
856
  else:
857
  return "❌ Comic generation failed"
858
  except Exception as e:
 
870
  ydl.download([link])
871
  success = comic_generator.generate_comic()
872
  if success:
873
+ return "πŸŽ‰ Enhanced Comic Created Successfully! Please refresh your browser and go to the /comic endpoint."
 
874
  else:
875
  return "❌ Comic generation failed"
876
  except Exception as e:
 
925
 
926
  # --- FIX: Use __name__ == '__main__' for the execution block ---
927
  if __name__ == '__main__':
928
+ # --- CHANGE: Use the port assigned by Hugging Face Spaces or default to 5000 ---
929
+ # This makes the app compatible with HF Spaces and also allows local execution.
930
+ port = int(os.getenv("PORT", 5000))
931
+
932
  print("πŸš€ Starting Enhanced Comic Generator...")
933
+ print(f"🌐 Web interface starting on host 0.0.0.0, port {port}")
934
+ # In Hugging Face Spaces, you will access the app through the public URL provided, not localhost.
935
+
936
+ app.run(debug=False, host='0.0.0.0', port=port)