idkash1 commited on
Commit
dab9f5f
·
verified ·
1 Parent(s): c4342c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -18,6 +18,9 @@ import threading
18
  import uuid
19
  import time
20
  from human_text_detect import detect_human_text
 
 
 
21
 
22
  app = Flask(__name__)
23
  CORS(app)
@@ -62,6 +65,10 @@ def process_analysis(task_id, text, model_name, topic, threshold):
62
 
63
  @app.route('/detectHumanInAIText/checkText', methods=['POST'])
64
  def check_text():
 
 
 
 
65
  # Get data
66
  print('Get data')
67
  data = request.get_json()
@@ -82,6 +89,10 @@ def check_text():
82
 
83
  @app.route('/detectHumanInAIText/getAnalyzeResults', methods=['GET'])
84
  def get_results():
 
 
 
 
85
  task_id = request.args.get('taskId')
86
 
87
  if not task_id:
 
18
  import uuid
19
  import time
20
  from human_text_detect import detect_human_text
21
+ import os
22
+
23
+ HF_TOKEN = os.getenv("HF_TOKEN")
24
 
25
  app = Flask(__name__)
26
  CORS(app)
 
65
 
66
  @app.route('/detectHumanInAIText/checkText', methods=['POST'])
67
  def check_text():
68
+ received_token = request.headers.get("HF_TOKEN")
69
+ if received_token != HF_TOKEN:
70
+ return jsonify({"error": "Unauthorized"}), 403 # Forbidden
71
+
72
  # Get data
73
  print('Get data')
74
  data = request.get_json()
 
89
 
90
  @app.route('/detectHumanInAIText/getAnalyzeResults', methods=['GET'])
91
  def get_results():
92
+ received_token = request.headers.get("HF_TOKEN")
93
+ if received_token != HF_TOKEN:
94
+ return jsonify({"error": "Unauthorized"}), 403 # Forbidden
95
+
96
  task_id = request.args.get('taskId')
97
 
98
  if not task_id: