Spaces:
Running
Running
Dax451
commited on
Commit
·
52c98dd
1
Parent(s):
c064060
Semplificata l'implementazione seguendo le best practice di Hugging Face
Browse files
app.py
CHANGED
@@ -277,25 +277,21 @@ def main():
|
|
277 |
username = os.getenv("GRADIO_USERNAME")
|
278 |
password = os.getenv("GRADIO_PASSWORD")
|
279 |
|
280 |
-
#
|
281 |
-
is_huggingface_space = os.getenv("SPACE_ID") is not None
|
282 |
-
|
283 |
-
# Parametri di lancio di base
|
284 |
launch_kwargs = {
|
285 |
-
"server_name": "0.0.0.0"
|
286 |
}
|
287 |
|
288 |
-
#
|
289 |
if username and password:
|
290 |
print(f"Autenticazione configurata con username: {username}")
|
291 |
-
# Usa lista di tuple per le credenziali
|
292 |
launch_kwargs["auth"] = [(username, password)]
|
293 |
else:
|
294 |
-
|
295 |
-
print("Autenticazione disabilitata per test locali. Su HF Spaces, imposta GRADIO_USERNAME e GRADIO_PASSWORD.")
|
296 |
|
297 |
-
#
|
298 |
-
if
|
|
|
299 |
launch_kwargs["share"] = True
|
300 |
|
301 |
# Avvia l'interfaccia
|
|
|
277 |
username = os.getenv("GRADIO_USERNAME")
|
278 |
password = os.getenv("GRADIO_PASSWORD")
|
279 |
|
280 |
+
# Parametri di base per il lancio
|
|
|
|
|
|
|
281 |
launch_kwargs = {
|
282 |
+
"server_name": "0.0.0.0",
|
283 |
}
|
284 |
|
285 |
+
# Verifica le credenziali e configura l'autenticazione se necessario
|
286 |
if username and password:
|
287 |
print(f"Autenticazione configurata con username: {username}")
|
|
|
288 |
launch_kwargs["auth"] = [(username, password)]
|
289 |
else:
|
290 |
+
print("Autenticazione disabilitata. Su HF Spaces, imposta GRADIO_USERNAME e GRADIO_PASSWORD.")
|
|
|
291 |
|
292 |
+
# Rileva se siamo su Hugging Face Spaces
|
293 |
+
if os.getenv("SPACE_ID") is None:
|
294 |
+
# Non siamo su HF Spaces, aggiungi share per renderlo accessibile
|
295 |
launch_kwargs["share"] = True
|
296 |
|
297 |
# Avvia l'interfaccia
|