jhh6576 commited on
Commit
3351b41
·
verified ·
1 Parent(s): 51f0bd8

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +138 -2
app_enhanced.py CHANGED
@@ -65,6 +65,142 @@ except Exception as e:
65
 
66
  app = Flask(__name__)
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  os.makedirs('video', exist_ok=True)
69
  os.makedirs('frames/final', exist_ok=True)
70
  os.makedirs('output', exist_ok=True)
@@ -1024,7 +1160,7 @@ comic_generator = EnhancedComicGenerator()
1024
 
1025
  @app.route('/')
1026
  def index():
1027
- return render_template('index.html')
1028
 
1029
  @app.route('/uploader', methods=['POST'])
1030
  def upload_file():
@@ -1050,7 +1186,7 @@ def handle_link():
1050
  link = request.form.get('link', '')
1051
  if not link: return "❌ No link provided"
1052
  import yt_dlp
1053
- ydl_opts = {'outtmpl': comic_generator.video_path, 'format': 'best[height<=720]'}
1054
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
1055
  ydl.download([link])
1056
  success = comic_generator.generate_comic()
 
65
 
66
  app = Flask(__name__)
67
 
68
+ # --- NEW: Embedded HTML for the main page with new UI ---
69
+ INDEX_HTML = '''
70
+ <!DOCTYPE html>
71
+ <html lang="en">
72
+ <head>
73
+ <meta charset="UTF-8">
74
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
75
+ <title>Movie to Comic Generator</title>
76
+ <style>
77
+ body {
78
+ background-color: #fdf6e3; /* Cream background */
79
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
80
+ color: #3d3d3d;
81
+ display: flex;
82
+ justify-content: center;
83
+ align-items: center;
84
+ min-height: 100vh;
85
+ margin: 0;
86
+ }
87
+ .container {
88
+ max-width: 500px;
89
+ width: 100%;
90
+ padding: 40px;
91
+ background-color: #ffffff;
92
+ border-radius: 12px;
93
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
94
+ text-align: center;
95
+ }
96
+ h1 {
97
+ color: #2c3e50;
98
+ margin-bottom: 30px;
99
+ font-weight: 600;
100
+ }
101
+ .upload-section, .url-section {
102
+ margin-bottom: 30px;
103
+ }
104
+ .file-input {
105
+ display: none;
106
+ }
107
+ .file-label {
108
+ display: block;
109
+ padding: 15px 25px;
110
+ background-color: #2c3e50; /* Dark Slate Blue */
111
+ color: white;
112
+ border-radius: 8px;
113
+ cursor: pointer;
114
+ font-size: 16px;
115
+ font-weight: 500;
116
+ transition: background-color 0.3s ease, transform 0.2s ease;
117
+ }
118
+ .file-label:hover {
119
+ background-color: #34495e;
120
+ transform: translateY(-2px);
121
+ }
122
+ #file-name {
123
+ display: block;
124
+ margin-top: 15px;
125
+ font-style: italic;
126
+ color: #7f8c8d;
127
+ }
128
+ .submit-btn {
129
+ width: 100%;
130
+ padding: 15px;
131
+ border: none;
132
+ border-radius: 8px;
133
+ background-color: #e67e22; /* Carrot Orange */
134
+ color: white;
135
+ font-size: 18px;
136
+ font-weight: bold;
137
+ cursor: pointer;
138
+ transition: background-color 0.3s ease;
139
+ }
140
+ .submit-btn:hover {
141
+ background-color: #d35400;
142
+ }
143
+ .separator {
144
+ border-bottom: 1px solid #e0e0e0;
145
+ margin: 30px 0;
146
+ }
147
+ input[type="text"] {
148
+ width: calc(100% - 22px);
149
+ padding: 12px;
150
+ border: 1px solid #bdc3c7;
151
+ border-radius: 8px;
152
+ font-size: 16px;
153
+ margin-bottom: 10px;
154
+ }
155
+ .disabled-section input, .disabled-section button {
156
+ opacity: 0.5;
157
+ cursor: not-allowed;
158
+ pointer-events: none;
159
+ }
160
+ .coming-soon {
161
+ font-weight: bold;
162
+ color: #95a5a6;
163
+ margin-top: -5px;
164
+ margin-bottom: 15px;
165
+ }
166
+ </style>
167
+ </head>
168
+ <body>
169
+ <div class="container">
170
+ <h1>🎬 Movie to Comic Generator</h1>
171
+
172
+ <form action="/uploader" method="post" enctype="multipart/form-data">
173
+ <div class="upload-section">
174
+ <label for="file-upload" class="file-label">Choose Video File</label>
175
+ <input id="file-upload" class="file-input" type="file" name="file" onchange="updateFileName(this)">
176
+ <span id="file-name">No file selected</span>
177
+ </div>
178
+ <button class="submit-btn" type="submit">Generate Comic</button>
179
+ </form>
180
+
181
+ <div class="separator"></div>
182
+
183
+ <div class="url-section disabled-section">
184
+ <input type="text" name="link" placeholder="Enter Video URL" disabled>
185
+ <p class="coming-soon">Coming Soon!</p>
186
+ <button class="submit-btn" type="submit" disabled>Generate from URL</button>
187
+ </div>
188
+ </div>
189
+
190
+ <script>
191
+ function updateFileName(input) {
192
+ const fileNameSpan = document.getElementById('file-name');
193
+ if (input.files && input.files.length > 0) {
194
+ fileNameSpan.textContent = input.files[0].name;
195
+ } else {
196
+ fileNameSpan.textContent = 'No file selected';
197
+ }
198
+ }
199
+ </script>
200
+ </body>
201
+ </html>
202
+ '''
203
+
204
  os.makedirs('video', exist_ok=True)
205
  os.makedirs('frames/final', exist_ok=True)
206
  os.makedirs('output', exist_ok=True)
 
1160
 
1161
  @app.route('/')
1162
  def index():
1163
+ return INDEX_HTML
1164
 
1165
  @app.route('/uploader', methods=['POST'])
1166
  def upload_file():
 
1186
  link = request.form.get('link', '')
1187
  if not link: return "❌ No link provided"
1188
  import yt_dlp
1189
+ ydl_opts = {'outtmpl': comic_generator.video_path, 'format': 'best[height<=720]', 'overwrites': True}
1190
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
1191
  ydl.download([link])
1192
  success = comic_generator.generate_comic()