Skip to content

Commit 9e4b97c

Browse files
🚀 feat(main.py): introduce OPEN_URL_IN_BROWSER flag for customizable control over opening the uploaded file URL in the browser
1 parent c901ba5 commit 9e4b97c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎main.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from mimetypes import guess_type
22
from os.path import basename, isfile, splitext, getsize, exists
33
from time import sleep
4+
from webbrowser import open
45

56
from pyperclip import copy
67
from requests import post
@@ -21,6 +22,8 @@
2122
# For detailed information on available options, refer to the official documentation:
2223
# https://zipline.diced.sh/docs/guides/upload-options
2324
UPLOAD_OPTIONS = {"Format": "RANDOM", "Embed": "false"}
25+
# Used to decide if the URL for the uploaded files should open in the browser.
26+
OPEN_URL_IN_BROWSER = False
2427

2528

2629
def validate_file(path):
@@ -99,6 +102,9 @@ def upload_file(self, event):
99102
if response.status_code == 200:
100103
print(f"File uploaded successfully: {response.json()['files'][0]}")
101104
copy(response.json()["files"][0]) # Copy the URL to the clipboard
105+
106+
if OPEN_URL_IN_BROWSER:
107+
open(response.json()["files"][0]) # Open the uploaded file in the browser if OPEN_URL_IN_BROWSER
102108
elif response.status_code == 401:
103109
print("Authentication failed. Please check your USER_ACCESS_TOKEN.")
104110
else:

0 commit comments

Comments
 (0)