priaansh commited on
Commit
5d1580f
·
verified ·
1 Parent(s): 80e4c8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import boto3
3
  from flask import Flask, jsonify
4
 
5
- # Load environment variables (from mounted secrets)
6
  API_KEY = os.getenv("API_KEY")
7
  S3_ENDPOINT_URL = os.getenv("S3_ENDPOINT_URL")
8
  S3_ACCESS_KEY = os.getenv("S3_ACCESS_KEY")
@@ -10,6 +10,12 @@ S3_SECRET_KEY = os.getenv("S3_SECRET_KEY")
10
  S3_BUCKET_NAME = os.getenv("S3_BUCKET_NAME")
11
  S3_REGION = os.getenv("S3_REGION")
12
 
 
 
 
 
 
 
13
  app = Flask(__name__)
14
 
15
  # Setup S3 client
@@ -35,5 +41,23 @@ def list_files():
35
  except Exception as e:
36
  return jsonify({"error": str(e)}), 500
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  if __name__ == "__main__":
39
- app.run(host="0.0.0.0", port=8080)
 
2
  import boto3
3
  from flask import Flask, jsonify
4
 
5
+ # Load environment variables (from mounted secrets or defaults)
6
  API_KEY = os.getenv("API_KEY")
7
  S3_ENDPOINT_URL = os.getenv("S3_ENDPOINT_URL")
8
  S3_ACCESS_KEY = os.getenv("S3_ACCESS_KEY")
 
10
  S3_BUCKET_NAME = os.getenv("S3_BUCKET_NAME")
11
  S3_REGION = os.getenv("S3_REGION")
12
 
13
+ # Ensure required environment variables are present
14
+ if not API_KEY:
15
+ raise ValueError("API_KEY environment variable is not set")
16
+ if not S3_ENDPOINT_URL or not S3_ACCESS_KEY or not S3_SECRET_KEY or not S3_BUCKET_NAME or not S3_REGION:
17
+ raise ValueError("S3 environment variables are not fully set")
18
+
19
  app = Flask(__name__)
20
 
21
  # Setup S3 client
 
41
  except Exception as e:
42
  return jsonify({"error": str(e)}), 500
43
 
44
+ @app.route("/v1/toolkit/test", methods=["GET"])
45
+ def test_toolkit():
46
+ return jsonify({"message": "Test route for toolkit"})
47
+
48
+ @app.route("/authenticate", methods=["GET"])
49
+ def authenticate():
50
+ return jsonify({"message": "Authentication endpoint"})
51
+
52
+ @app.route("/v1/ffmpeg/compose", methods=["POST"])
53
+ def ffmpeg_compose():
54
+ # Placeholder for your FFmpeg logic
55
+ return jsonify({"message": "FFmpeg compose endpoint"})
56
+
57
+ # List all available routes (for debugging purposes)
58
+ @app.route("/routes", methods=["GET"])
59
+ def list_routes():
60
+ return jsonify({"routes": [str(rule) for rule in app.url_map.iter_rules()]})
61
+
62
  if __name__ == "__main__":
63
+ app.run(host="0.0.0.0", port=8080)