diff --git a/desktop_env/server/main.py b/desktop_env/server/main.py index 847f28b..cccb0d4 100644 --- a/desktop_env/server/main.py +++ b/desktop_env/server/main.py @@ -465,7 +465,7 @@ def get_directory_tree(): def get_file(): # Retrieve filename from the POST request if 'file_path' in request.form: - file_path = request.form['file_path'] + file_path = os.path.expanduser(request.form['file_path']) else: return jsonify({"error": "file_path is required"}), 400 @@ -481,7 +481,7 @@ def get_file(): def upload_file(): # Retrieve filename from the POST request if 'file_path' in request.form and 'file_data' in request.files: - file_path = request.form['file_path'] + file_path = os.path.expanduser(request.form['file_path']) file = request.files["file_data"] file.save(file_path) return "File Uploaded" @@ -507,7 +507,7 @@ def change_wallpaper(): if not path: return "Path not supplied!", 400 - path = Path(path) + path = Path(os.path.expanduser(path)) if not path.exists(): return f"File not found: {path}", 404 @@ -538,7 +538,7 @@ def download_file(): if not url or not path: return "Path or URL not supplied!", 400 - path = Path(path) + path = Path(os.path.expanduser(path)) path.parent.mkdir(parents=True, exist_ok=True) max_retries = 3 @@ -567,7 +567,7 @@ def open_file(): if not path: return "Path not supplied!", 400 - path = Path(path) + path = Path(os.path.expanduser(path)) if not path.exists(): return f"File not found: {path}", 404