Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,6 +56,17 @@ def azure_login_with_playwright(username, password):
|
|
56 |
st.error(f"An error occurred during browser simulation: {str(e)}")
|
57 |
return False
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# Function to install Playwright browsers
|
60 |
def install_playwright_browsers():
|
61 |
try:
|
@@ -139,8 +150,10 @@ if not st.session_state.logged_in:
|
|
139 |
if not PLAYWRIGHT_INSTALLED:
|
140 |
st.warning("Playwright is not installed. Please install it to use browser simulation.")
|
141 |
if st.button("Install Playwright"):
|
142 |
-
if
|
143 |
-
|
|
|
|
|
144 |
else:
|
145 |
username = st.text_input("Azure Username/Email")
|
146 |
password = st.text_input("Azure Password", type="password")
|
|
|
56 |
st.error(f"An error occurred during browser simulation: {str(e)}")
|
57 |
return False
|
58 |
|
59 |
+
# Function to install Playwright
|
60 |
+
def install_playwright():
|
61 |
+
try:
|
62 |
+
subprocess.run([sys.executable, "-m", "pip", "install", "playwright"],
|
63 |
+
capture_output=True, text=True, check=True)
|
64 |
+
st.success("Playwright installed successfully!")
|
65 |
+
return True
|
66 |
+
except subprocess.CalledProcessError as e:
|
67 |
+
st.error(f"Failed to install Playwright. Error: {e.stderr}")
|
68 |
+
return False
|
69 |
+
|
70 |
# Function to install Playwright browsers
|
71 |
def install_playwright_browsers():
|
72 |
try:
|
|
|
150 |
if not PLAYWRIGHT_INSTALLED:
|
151 |
st.warning("Playwright is not installed. Please install it to use browser simulation.")
|
152 |
if st.button("Install Playwright"):
|
153 |
+
if install_playwright():
|
154 |
+
if install_playwright_browsers():
|
155 |
+
st.success("Playwright and browsers installed successfully. Please restart the app.")
|
156 |
+
st.stop()
|
157 |
else:
|
158 |
username = st.text_input("Azure Username/Email")
|
159 |
password = st.text_input("Azure Password", type="password")
|