Update src/streamlit_app.py
Browse files- src/streamlit_app.py +19 -10
src/streamlit_app.py
CHANGED
@@ -21,9 +21,9 @@
|
|
21 |
|
22 |
|
23 |
import os, types, streamlit as st
|
24 |
-
import
|
|
|
25 |
os.environ['STREAMLIT_CONFIG_DIR'] = '/tmp/.streamlit'
|
26 |
-
# Fetch the hidden code from env var
|
27 |
app_code = os.environ.get("APP_CODE", "")
|
28 |
|
29 |
def execute_code(code_str):
|
@@ -32,21 +32,30 @@ def execute_code(code_str):
|
|
32 |
exec(code_str, module.__dict__)
|
33 |
if hasattr(module, "main"):
|
34 |
module.main()
|
|
|
35 |
except Exception as e:
|
36 |
st.error(f"Error in hidden code: {e}")
|
37 |
-
|
38 |
-
# if app_code:
|
39 |
-
# execute_code(app_code)
|
40 |
-
|
41 |
-
# else:
|
42 |
-
# st.error("APP_CODE is empty. Did you set it?")
|
43 |
|
44 |
def main():
|
|
|
|
|
45 |
if app_code:
|
46 |
-
execute_code(app_code)
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
else:
|
49 |
st.error("APP_CODE is empty. Did you set it?")
|
|
|
|
|
|
|
50 |
st.set_page_config(layout="wide")
|
51 |
|
52 |
# Sidebar for navigation
|
|
|
21 |
|
22 |
|
23 |
import os, types, streamlit as st
|
24 |
+
import requests # Make sure to import requests if used
|
25 |
+
|
26 |
os.environ['STREAMLIT_CONFIG_DIR'] = '/tmp/.streamlit'
|
|
|
27 |
app_code = os.environ.get("APP_CODE", "")
|
28 |
|
29 |
def execute_code(code_str):
|
|
|
32 |
exec(code_str, module.__dict__)
|
33 |
if hasattr(module, "main"):
|
34 |
module.main()
|
35 |
+
return module
|
36 |
except Exception as e:
|
37 |
st.error(f"Error in hidden code: {e}")
|
38 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
def main():
|
41 |
+
global job_posts, api_endpoint, hf_token, simulated_code_animation, generate_email, generate_phone_number, generate_linkedin
|
42 |
+
|
43 |
if app_code:
|
44 |
+
module = execute_code(app_code)
|
45 |
+
if module:
|
46 |
+
# Extract required variables and functions from the module
|
47 |
+
job_posts = getattr(module, 'job_posts', [])
|
48 |
+
api_endpoint = getattr(module, 'api_endpoint', '')
|
49 |
+
hf_token = getattr(module, 'hf_token', '')
|
50 |
+
simulated_code_animation = getattr(module, 'simulated_code_animation', lambda x: None)
|
51 |
+
generate_email = getattr(module, 'generate_email', lambda x: "[email protected]")
|
52 |
+
generate_phone_number = getattr(module, 'generate_phone_number', lambda: "555-123-4567")
|
53 |
+
generate_linkedin = getattr(module, 'generate_linkedin', lambda x: "linkedin.com/in/example")
|
54 |
else:
|
55 |
st.error("APP_CODE is empty. Did you set it?")
|
56 |
+
return
|
57 |
+
|
58 |
+
|
59 |
st.set_page_config(layout="wide")
|
60 |
|
61 |
# Sidebar for navigation
|