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 lines425426427428429430424 unmodified linesdef main():"""Main Streamlit application"""# Show loading indicatorwith st.spinner("π Initializing FRED ML Platform..."):# Load configuration424 unmodified lines425426427428429430431432433434435436437438439440424 unmodified linesdef main():"""Main Streamlit application"""# Check for FRED API key firstfred_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 printst.write(f"π FRED API Key loaded: {fred_key[:8]}...")# Show loading indicatorwith st.spinner("π Initializing FRED ML Platform..."):# Load configuration
5 unmodified lines6789101120 unmodified lines323334353637384 unmodified lines4344454647485 unmodified linesimport sysimport os# Add the frontend directory to the pathcurrent_dir = os.path.dirname(os.path.abspath(__file__))20 unmodified linesexcept ImportError as e2:print(f"Error importing from app: {e2}")# Last resort: define a simple main functionimport streamlit as stdef main():st.error("Failed to import main application. Please check the deployment.")st.info("Contact support if this issue persists.")4 unmodified linesif main is not None:main()else:import streamlit as stst.error("Failed to import main application. Please check the deployment.")st.info("Contact support if this issue persists.")5 unmodified lines67891011121314151617181920212223242520 unmodified lines4647484950514 unmodified lines56575859605 unmodified linesimport 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 linesexcept ImportError as e2:print(f"Error importing from app: {e2}")# Last resort: define a simple main functiondef main():st.error("Failed to import main application. Please check the deployment.")st.info("Contact support if this issue persists.")4 unmodified linesif main is not None:main()else: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