Bhuvi13 commited on
Commit
2be165a
·
verified ·
1 Parent(s): 56755a8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +14 -0
src/streamlit_app.py CHANGED
@@ -22,6 +22,20 @@ try:
22
  except Exception as e:
23
  print(f"[startup] WARNING: could not create {streamlit_dir}: {e}")
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  # -----------------------------
26
  # Imports
27
  # -----------------------------
 
22
  except Exception as e:
23
  print(f"[startup] WARNING: could not create {streamlit_dir}: {e}")
24
 
25
+ # HF Spaces serves the app behind an iframe/proxy, which makes Streamlit's
26
+ # default XSRF Origin check reject the file-uploader's POST with 403 even
27
+ # though the websocket connection works fine. Disable it via config.toml.
28
+ _config_toml = streamlit_dir / "config.toml"
29
+ try:
30
+ if not _config_toml.exists():
31
+ _config_toml.write_text(
32
+ "[server]\nenableXsrfProtection = false\nenableCORS = false\n",
33
+ encoding="utf-8",
34
+ )
35
+ print(f"[startup] wrote {_config_toml}")
36
+ except Exception as e:
37
+ print(f"[startup] WARNING: could not write {_config_toml}: {e}")
38
+
39
  # -----------------------------
40
  # Imports
41
  # -----------------------------