Yaroslav95 commited on
Commit
371f28f
·
1 Parent(s): 05e19d0
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -192,10 +192,21 @@ iface = gr.Interface(
192
  submit_btn="Get quote",
193
  )
194
 
195
- valid_users = [("admin", "password123"), ("user1", "pass456")]
196
 
197
- iface.launch(
198
- debug=True,
199
- auth=("username", "password"),
200
- auth_message="Try this",
201
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  submit_btn="Get quote",
193
  )
194
 
 
195
 
196
+ def auth_function(username, password):
197
+ valid_users = {"admin": "password123", "user1": "pass456"}
198
+ return username in valid_users and valid_users[username] == password
199
+
200
+
201
+ if os.getenv("SPACE_ID"):
202
+ # We're running on HF Spaces
203
+ iface.launch(
204
+ auth=auth_function, server_name="0.0.0.0", server_port=7860, share=False
205
+ )
206
+ else:
207
+ # We're running locally
208
+ iface.launch(
209
+ debug=True,
210
+ auth=[("admin", "password123"), ("user1", "pass456")],
211
+ server_name="127.0.0.1",
212
+ )