Muhammad Waqas commited on
Commit
a84ba92
·
1 Parent(s): d9bc1e6

Added: Generate image to video

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -169,7 +169,8 @@ def generate_image():
169
  ws = websocket.WebSocket()
170
 
171
  try:
172
- ws.connect(f"{ws_address}?clientId={client_id}&token={token}")
 
173
  except websocket.WebSocketException as e:
174
  return jsonify({'error': f'WebSocket connection failed: {str(e)}'}), 500
175
 
@@ -198,9 +199,12 @@ def image_to_video():
198
 
199
  # Extract token from headers
200
  token = request.headers.get('Authorization')
201
- if not token or not token.startswith("Bearer "):
202
- return jsonify({'error': 'Invalid or missing token'}), 400
203
- token = base64.b64decode(token.split(" ")[1]).decode("utf-8")
 
 
 
204
 
205
  # Extract text prompt
206
  text_prompt = data.get('text_prompt')
@@ -244,7 +248,8 @@ def image_to_video():
244
 
245
  # WebSocket connection to trigger workflow
246
  ws = websocket.WebSocket()
247
- ws.connect(f"{ws_address}?clientId={client_id}&token={token}")
 
248
  ws.send(json.dumps({"workflow": workflow})) # Send the modified workflow
249
 
250
  # Receive video processing result
 
169
  ws = websocket.WebSocket()
170
 
171
  try:
172
+ ws.connect(f"{ws_address}?clientId={client_id}&token={token}", header=
173
+ {"Authorization": f"Bearer {token}"})
174
  except websocket.WebSocketException as e:
175
  return jsonify({'error': f'WebSocket connection failed: {str(e)}'}), 500
176
 
 
199
 
200
  # Extract token from headers
201
  token = request.headers.get('Authorization')
202
+ if token is None:
203
+ return jsonify({'error': 'No token provided'}), 400
204
+ if token.startswith("Bearer "):
205
+ token = token.split(" ")[1]
206
+
207
+ # token = base64.b64decode(token).decode("utf-8")
208
 
209
  # Extract text prompt
210
  text_prompt = data.get('text_prompt')
 
248
 
249
  # WebSocket connection to trigger workflow
250
  ws = websocket.WebSocket()
251
+ ws.connect(f"{ws_address}?clientId={client_id}&token={token}", header=
252
+ {"Authorization": f"Bearer {token}"})
253
  ws.send(json.dumps({"workflow": workflow})) # Send the modified workflow
254
 
255
  # Receive video processing result