Edwin Salguero commited on
Commit ยท
378ea47
1
Parent(s): 2cebf25
Add FRED API key validation at app startup and improve environment variable loading
Browse filesFiles changed (2)
- frontend/app.py+10
- streamlit_app.py+14-2
424 unmodified lines425426427428429430431432433434435436437438439440424 unmodified linesdef main(): """Main Streamlit application""" # Check for FRED API key first fred_key = os.getenv("FRED_API_KEY") or st.secrets.get("FRED_API_KEY") if not fred_key: st.error("โ FRED API not available. Please configure your FRED API key.") st.info("Get a free FRED API key at: https://fred.stlouisfed.org/docs/api/api_key.html") st.stop() # Add debug print st.write(f"๐ FRED API Key loaded: {fred_key[:8]}...") # Show loading indicator with st.spinner("๐ Initializing FRED ML Platform..."): # Load configuration5 unmodified lines67891011121314151617181920212223242520 unmodified lines464748354950514 unmodified lines5657584659605 unmodified lines
import sysimport osimport streamlit as stfrom dotenv import load_dotenv
# Load environment variables from .env fileload_dotenv()
# Check for FRED API keyfred_key = os.getenv("FRED_API_KEY") or st.secrets.get("FRED_API_KEY")if not fred_key: st.error("โ FRED API not available. Please configure your FRED API key.") st.stop()
# Add debug printst.write(f"๐ FRED API Key loaded: {fred_key[:8]}...")
# Add the frontend directory to the pathcurrent_dir = os.path.dirname(os.path.abspath(__file__))20 unmodified lines except ImportError as e2: print(f"Error importing from app: {e2}") # Last resort: define a simple main function import streamlit as st def main(): st.error("Failed to import main application. Please check the deployment.") st.info("Contact support if this issue persists.")4 unmodified lines if main is not None: main() else: import streamlit as st st.error("Failed to import main application. Please check the deployment.") st.info("Contact support if this issue persists.") frontend/app.py+10
streamlit_app.py+14-2