Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import gc
|
|
| 5 |
import spaces
|
| 6 |
import xml.etree.ElementTree as ET
|
| 7 |
import re
|
|
|
|
| 8 |
|
| 9 |
# Clear GPU memory
|
| 10 |
torch.cuda.empty_cache()
|
|
@@ -135,6 +136,27 @@ def generate_svg(prompt):
|
|
| 135 |
|
| 136 |
return svg_code, svg_display
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# Minimal CSS for slightly larger HTML preview only
|
| 139 |
custom_css = """
|
| 140 |
div[data-testid="HTML"] {
|
|
@@ -158,6 +180,4 @@ gradio_app = gr.Interface(
|
|
| 158 |
)
|
| 159 |
|
| 160 |
if __name__ == "__main__":
|
| 161 |
-
gradio_app.launch()
|
| 162 |
-
|
| 163 |
-
|
|
|
|
| 5 |
import spaces
|
| 6 |
import xml.etree.ElementTree as ET
|
| 7 |
import re
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
# Clear GPU memory
|
| 11 |
torch.cuda.empty_cache()
|
|
|
|
| 136 |
|
| 137 |
return svg_code, svg_display
|
| 138 |
|
| 139 |
+
# Authentication function using HF Space secrets
|
| 140 |
+
def authenticate(username, password):
|
| 141 |
+
"""
|
| 142 |
+
Authentication function for Gradio using HF Space secrets
|
| 143 |
+
Returns True if credentials are valid, False otherwise
|
| 144 |
+
"""
|
| 145 |
+
# Get credentials from HF Space secrets
|
| 146 |
+
valid_username = os.getenv("user") # This matches your secret name "user"
|
| 147 |
+
valid_password = os.getenv("password") # This matches your secret name "password"
|
| 148 |
+
|
| 149 |
+
# Fallback credentials if secrets are not available (for local testing)
|
| 150 |
+
if valid_username is None:
|
| 151 |
+
valid_username = "user"
|
| 152 |
+
print("Warning: 'user' secret not found, using fallback")
|
| 153 |
+
|
| 154 |
+
if valid_password is None:
|
| 155 |
+
valid_password = "password"
|
| 156 |
+
print("Warning: 'password' secret not found, using fallback")
|
| 157 |
+
|
| 158 |
+
return username == valid_username and password == valid_password
|
| 159 |
+
|
| 160 |
# Minimal CSS for slightly larger HTML preview only
|
| 161 |
custom_css = """
|
| 162 |
div[data-testid="HTML"] {
|
|
|
|
| 180 |
)
|
| 181 |
|
| 182 |
if __name__ == "__main__":
|
| 183 |
+
gradio_app.launch(auth=authenticate)
|
|
|
|
|
|