Spaces:
Sleeping
Sleeping
Update proxy/upload_api.py
Browse files- proxy/upload_api.py +16 -5
proxy/upload_api.py
CHANGED
|
@@ -6,22 +6,33 @@ app = Flask(__name__)
|
|
| 6 |
DATA_DIR = "/data"
|
| 7 |
os.makedirs(DATA_DIR, exist_ok=True)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
def debug_conllu():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
try:
|
| 11 |
ls_output = subprocess.check_output(
|
| 12 |
-
["bash", "-c", "ls -R
|
| 13 |
stderr=subprocess.STDOUT
|
| 14 |
).decode()
|
|
|
|
|
|
|
| 15 |
|
|
|
|
| 16 |
grep_output = subprocess.check_output(
|
| 17 |
-
["bash", "-c", "grep -R \"12345\"
|
| 18 |
stderr=subprocess.STDOUT
|
| 19 |
).decode()
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
except Exception as e:
|
| 24 |
-
return f"Error: {e}"
|
| 25 |
|
| 26 |
@app.route("/api/debug", methods=["GET"])
|
| 27 |
def debug():
|
|
|
|
| 6 |
DATA_DIR = "/data"
|
| 7 |
os.makedirs(DATA_DIR, exist_ok=True)
|
| 8 |
|
| 9 |
+
import subprocess
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
def debug_conllu():
|
| 13 |
+
base = "/usr/src/ConlluEditor"
|
| 14 |
+
|
| 15 |
+
if not os.path.exists(base):
|
| 16 |
+
return f"Directory does not exist: {base}"
|
| 17 |
+
|
| 18 |
try:
|
| 19 |
ls_output = subprocess.check_output(
|
| 20 |
+
["bash", "-c", f"ls -R {base}"],
|
| 21 |
stderr=subprocess.STDOUT
|
| 22 |
).decode()
|
| 23 |
+
except subprocess.CalledProcessError as e:
|
| 24 |
+
ls_output = f"ls failed:\n{e.output.decode()}"
|
| 25 |
|
| 26 |
+
try:
|
| 27 |
grep_output = subprocess.check_output(
|
| 28 |
+
["bash", "-c", f"grep -R \"12345\" {base} || true"],
|
| 29 |
stderr=subprocess.STDOUT
|
| 30 |
).decode()
|
| 31 |
+
except subprocess.CalledProcessError as e:
|
| 32 |
+
grep_output = f"grep failed:\n{e.output.decode()}"
|
| 33 |
|
| 34 |
+
return f"=== ls -R ===\n{ls_output}\n\n=== grep ===\n{grep_output}"
|
| 35 |
|
|
|
|
|
|
|
| 36 |
|
| 37 |
@app.route("/api/debug", methods=["GET"])
|
| 38 |
def debug():
|