Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,3 @@
|
|
| 1 |
-
#https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/
|
| 2 |
-
#https://www.youtube.com/watch?v=qbLc5a9jdXo&ab_channel=CalebCurry
|
| 3 |
-
#https://stackoverflow.com/questions/26368306/export-is-not-recognized-as-an-internal-or-external-command
|
| 4 |
-
#python3 -m venv .venv
|
| 5 |
-
#source .venv/bin/activate
|
| 6 |
-
#
|
| 7 |
-
#pip freeze > requirements.txt
|
| 8 |
-
#$env:FLASK_APP="application.py" #set FLASK_APP=application.py # export FLASK_APP=application.py
|
| 9 |
-
#set FLASK_ENV=development #export FLASK_ENV=production
|
| 10 |
-
#flask run #flask run --host=0.0.0.0
|
| 11 |
-
|
| 12 |
-
#pip install torchvision
|
| 13 |
-
|
| 14 |
from flask import Flask, request, jsonify
|
| 15 |
from flask_cors import CORS
|
| 16 |
import pandas
|
|
@@ -66,8 +53,8 @@ def process_analysis(task_id, text, model_name, topic, threshold):
|
|
| 66 |
@app.route('/detectHumanInAIText/checkText', methods=['POST'])
|
| 67 |
def check_text():
|
| 68 |
received_token = request.headers.get("Authorization")
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
# Get data
|
| 73 |
print('Get data')
|
|
@@ -89,9 +76,9 @@ def check_text():
|
|
| 89 |
|
| 90 |
@app.route('/detectHumanInAIText/getAnalyzeResults', methods=['GET'])
|
| 91 |
def get_results():
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
|
| 96 |
task_id = request.args.get('taskId')
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from flask import Flask, request, jsonify
|
| 2 |
from flask_cors import CORS
|
| 3 |
import pandas
|
|
|
|
| 53 |
@app.route('/detectHumanInAIText/checkText', methods=['POST'])
|
| 54 |
def check_text():
|
| 55 |
received_token = request.headers.get("Authorization")
|
| 56 |
+
if received_token != HF_TOKEN:
|
| 57 |
+
return jsonify({"error": "Unauthorized"}), 403 # Forbidden
|
| 58 |
|
| 59 |
# Get data
|
| 60 |
print('Get data')
|
|
|
|
| 76 |
|
| 77 |
@app.route('/detectHumanInAIText/getAnalyzeResults', methods=['GET'])
|
| 78 |
def get_results():
|
| 79 |
+
received_token = request.headers.get("Authorization")
|
| 80 |
+
if received_token != HF_TOKEN:
|
| 81 |
+
return jsonify({"error": "Unauthorized"}), 403 # Forbidden
|
| 82 |
|
| 83 |
task_id = request.args.get('taskId')
|
| 84 |
|