Spaces:
Paused
Paused
Download app.py from noormos1234/secure-rag: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/noormos1234/secure-rag/resolve/main/app.py
- Command line
-
hf download hf://spaces/noormos1234/secure-rag/app.py
-
curl -L -o app.py https://huggingface.co/spaces/noormos1234/secure-rag/resolve/main/app.py
1.26 kB
| import os, sys, runpy | |
| import streamlit as st | |
| # Keys come from the environment (Space secrets), not from a secrets file. | |
| # If no secrets file exists, create an empty one so Streamlit does not show "No secrets files found". | |
| try: | |
| _sec = os.path.join(os.getcwd(), ".streamlit", "secrets.toml") | |
| _home = os.path.join(os.path.expanduser("~"), ".streamlit", "secrets.toml") | |
| if not os.path.exists(_sec) and not os.path.exists(_home): | |
| os.makedirs(os.path.dirname(_sec), exist_ok=True) | |
| open(_sec, "a").close() | |
| except Exception: | |
| pass | |
| # The main page (Secure RAG), unchanged | |
| _ns = runpy.run_path("old_secure_rag.py", run_name="__main__") | |
| # Shield uses the same file and link entered above | |
| st.session_state["_shield_embedded"] = True | |
| st.session_state["_shared_file"] = _ns.get("uploaded_file") | |
| st.session_state["_shared_url"] = _ns.get("url_input", "") | |
| st.divider() | |
| # Shield files sit next to this file on the Space (shield_app.py, shield_core.py) | |
| import shield_core | |
| sys.modules["core"] = shield_core | |
| _page, _title = st.set_page_config, st.title | |
| st.set_page_config = lambda *a, **k: None | |
| st.title = lambda *a, **k: None | |
| try: | |
| runpy.run_path("shield_app.py", run_name="__main__") | |
| finally: | |
| st.set_page_config, st.title = _page, _title | |