sujalrajpoot commited on
Commit
c031cee
·
verified ·
1 Parent(s): c20be55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -7,7 +7,7 @@ import logging
7
  logging.basicConfig(level=logging.INFO)
8
  app = Flask(__name__)
9
 
10
- # 🔑 Secret key for API authentication (Load from environment in production)
11
  SECRET_KEY = os.getenv("SECRET_KEY")
12
  GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
13
  SPECIAL_API_KEY = os.getenv("SPECIAL_API_KEY")
@@ -105,7 +105,6 @@ def generate_api_key():
105
  random_part = secrets.token_hex(16)
106
  signature = hmac.new(SECRET_KEY.encode(), random_part.encode(), hashlib.sha256).hexdigest()[:16]
107
  api_key = f"TrueSyncAI-{random_part}-{signature}"
108
-
109
  return jsonify({"api_key": api_key})
110
 
111
  # Chat Endpoint
@@ -115,7 +114,7 @@ def chat():
115
  data = request.json
116
  api_key = data.get("api_key")
117
  message = data.get("message", "").strip()
118
- logging.info(f"Request received: {data}\n")
119
 
120
  if not api_key or not validate_api_key(api_key):
121
  return jsonify({"error": "Invalid API Key"}), 401
 
7
  logging.basicConfig(level=logging.INFO)
8
  app = Flask(__name__)
9
 
10
+ # 🔑 Secret key for API authentication
11
  SECRET_KEY = os.getenv("SECRET_KEY")
12
  GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
13
  SPECIAL_API_KEY = os.getenv("SPECIAL_API_KEY")
 
105
  random_part = secrets.token_hex(16)
106
  signature = hmac.new(SECRET_KEY.encode(), random_part.encode(), hashlib.sha256).hexdigest()[:16]
107
  api_key = f"TrueSyncAI-{random_part}-{signature}"
 
108
  return jsonify({"api_key": api_key})
109
 
110
  # Chat Endpoint
 
114
  data = request.json
115
  api_key = data.get("api_key")
116
  message = data.get("message", "").strip()
117
+ logging.info(f"Request received: {data}")
118
 
119
  if not api_key or not validate_api_key(api_key):
120
  return jsonify({"error": "Invalid API Key"}), 401