Alibrown commited on
Commit
163eb6d
·
verified ·
1 Parent(s): 9ca9914

Update app/app.py

Browse files
Files changed (1) hide show
  1. app/app.py +22 -1
app/app.py CHANGED
@@ -1,19 +1,33 @@
 
1
  from flask import Flask, request, jsonify
2
  import os
 
 
 
 
 
3
 
4
  app = Flask(__name__)
5
 
 
 
 
 
 
6
  @app.route("/interactions", methods=["POST"])
7
  def interactions():
8
  data = request.json
 
9
 
10
  # Discord Ping Verification
11
  if data["type"] == 1:
 
12
  return jsonify({"type": 1})
13
 
14
  # Slash Command Handler
15
  if data["type"] == 2:
16
  command = data["data"]["name"]
 
17
  if command == "settings":
18
  return jsonify({
19
  "type": 4,
@@ -24,5 +38,12 @@ def interactions():
24
 
25
  return jsonify({})
26
 
 
 
 
 
 
27
  if __name__ == "__main__":
28
- app.run(host="0.0.0.0", port=int(os.getenv("PORT", 8080)))
 
 
 
1
+ # app/app.py
2
  from flask import Flask, request, jsonify
3
  import os
4
+ import logging
5
+
6
+ # Logging konfigurieren
7
+ logging.basicConfig(level=logging.INFO)
8
+ logger = logging.getLogger(__name__)
9
 
10
  app = Flask(__name__)
11
 
12
+ @app.route("/", methods=["GET"])
13
+ def health_check():
14
+ logger.info("Health check endpoint called")
15
+ return jsonify({"status": "healthy", "message": "Discord bot is running!"})
16
+
17
  @app.route("/interactions", methods=["POST"])
18
  def interactions():
19
  data = request.json
20
+ logger.info(f"Received interaction type: {data['type']}")
21
 
22
  # Discord Ping Verification
23
  if data["type"] == 1:
24
+ logger.info("Responding to ping verification")
25
  return jsonify({"type": 1})
26
 
27
  # Slash Command Handler
28
  if data["type"] == 2:
29
  command = data["data"]["name"]
30
+ logger.info(f"Received command: {command}")
31
  if command == "settings":
32
  return jsonify({
33
  "type": 4,
 
38
 
39
  return jsonify({})
40
 
41
+ @app.before_request
42
+ def log_request_info():
43
+ logger.info(f"Request Method: {request.method}")
44
+ logger.info(f"Request Path: {request.path}")
45
+
46
  if __name__ == "__main__":
47
+ logger.info("Starting Discord bot...")
48
+ app.run(host="0.0.0.0", port=int(os.getenv("PORT", 8080)))
49
+ logger.info("Discord bot is running!")