Update app_enhanced.py
Browse files- 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
|
| 854 |
-
|
|
|
|
| 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 |
-
|
| 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
|
| 930 |
-
app
|
|
|
|
|
|
|
|
|
| 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)
|