Merge branch 'zdy'

This commit is contained in:
David Chang
2023-12-21 10:42:18 +08:00
6 changed files with 106 additions and 64 deletions

View File

@@ -4,9 +4,10 @@ import platform
import subprocess
import requests
import Xlib.display
#import Xlib.display
import pyautogui
from PIL import ImageGrab, Image
#from PIL import ImageGrab, Image
from PIL import Image
from flask import Flask, request, jsonify, send_file
app = Flask(__name__)
@@ -180,7 +181,11 @@ def open_file():
return f"File not found: {path}", 404
try:
os.startfile(path)
if platform.system()=="Windows":
os.startfile(path)
else:
open_cmd: str = "open" if platform.system()=="Darwin" else "xdg-open"
subprocess.Popen([open_cmd, str(path)])
return "File opened successfully"
except Exception as e:
return f"Failed to open {path}. Error: {e}", 500