Spaces:
Running

mgokg commited on
Commit
09ece53
·
verified ·
1 Parent(s): c44421b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -1,11 +1,22 @@
1
- import gradio as gr
2
- from gradio_client import Client
3
  import os
 
 
 
 
 
 
 
 
 
 
4
 
5
- # Client initialization
6
  client = Client(
7
  "mgokg/puter",
8
- token=os.environ.get("HF_TOKEN"),
 
 
 
9
  )
10
 
11
  SYSTEM_PROMPT = "antworte kurz und knapp. optimiere deine antwort für sprachausgabe."
 
 
 
1
  import os
2
+ import base64
3
+ from gradio_client import Client
4
+
5
+ # Deine Zugangsdaten aus den Variablen
6
+ username = os.environ.get("APP_USERNAME")
7
+ password = os.environ.get("APP_PASSWORD")
8
+
9
+ # Zugangsdaten für Basic Auth kodieren
10
+ credentials = f"{username}:{password}"
11
+ encoded_credentials = base64.b64encode(credentials.encode("utf-8")).decode("utf-8")
12
 
13
+ # Client mit Headern initialisieren
14
  client = Client(
15
  "mgokg/puter",
16
+ hf_token=os.environ.get("HF_TOKEN"), # Korrekter Parameter bei gradio_client ist hf_token
17
+ headers={
18
+ "Authorization": f"Basic {encoded_credentials}"
19
+ }
20
  )
21
 
22
  SYSTEM_PROMPT = "antworte kurz und knapp. optimiere deine antwort für sprachausgabe."