Alibrown commited on
Commit
cc9e326
·
verified ·
1 Parent(s): d597c90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -1,7 +1,40 @@
1
- # app.py - Streamlit Version
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import streamlit as st
3
  from PIL import Image
4
  import io
 
5
 
6
  def stack_horizontal(img1, img2):
7
  """Stapelt zwei Bilder horizontal nebeneinander."""
 
1
+ # app.py - Streamlit für Hugging Face Spaces
2
+ import os
3
+ import tempfile
4
+
5
+ # ----------------------------------------------------
6
+ # 🚨 KRITISCHE FIXES FÜR DEN PERMISSION ERROR
7
+ # Zwingt Streamlit, seine temporären/Konfigurationsdateien
8
+ # in den beschreibbaren /tmp-Bereich zu schreiben.
9
+ # ----------------------------------------------------
10
+ # 1. Temporären, beschreibbaren Pfad erstellen
11
+ TEMP_STREAMLIT_HOME = os.path.join(tempfile.gettempdir(), "st_config_workaround")
12
+ os.makedirs(TEMP_STREAMLIT_HOME, exist_ok=True)
13
+
14
+ # 2. Umgebungsvariablen setzen
15
+ os.environ["STREAMLIT_HOME"] = TEMP_STREAMLIT_HOME
16
+ os.environ["STREAMLIT_GATHER_USAGE_STATS"] = "false"
17
+
18
+ # 3. Minimale config.toml erstellen, um Schreibversuche zu unterbinden
19
+ CONFIG_PATH = os.path.join(TEMP_STREAMLIT_HOME, "config.toml")
20
+ CONFIG_CONTENT = """
21
+ [browser]
22
+ gatherUsageStats = false
23
+
24
+ [server]
25
+ headless = true
26
+ port = 7860
27
+ enableCORS = false
28
+ """
29
+
30
+ with open(CONFIG_PATH, "w") as f:
31
+ f.write(CONFIG_CONTENT)
32
+
33
+ # JETZT erst Streamlit importieren!
34
  import streamlit as st
35
  from PIL import Image
36
  import io
37
+ import numpy as np
38
 
39
  def stack_horizontal(img1, img2):
40
  """Stapelt zwei Bilder horizontal nebeneinander."""