Spaces:
Running
Running
Update src/app.py
Browse files- src/app.py +1 -9
src/app.py
CHANGED
@@ -1,14 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
import os,types,requests
|
3 |
-
# from huggingface_hub import login
|
4 |
|
5 |
# Retrieve your hidden script from the environment variable
|
6 |
app_url = os.environ.get("APP_URL", "")
|
7 |
token = os.environ.get("HF_TOKEN", "")
|
8 |
|
9 |
-
# Pass the token as a string
|
10 |
-
# login(token=token)
|
11 |
-
|
12 |
def execute_remote_script(url: str): # code_str: str
|
13 |
"""
|
14 |
Dynamically compile and execute the provided url string.
|
@@ -22,16 +18,12 @@ def execute_remote_script(url: str): # code_str: str
|
|
22 |
|
23 |
# Get the script content as a string
|
24 |
code_string = response.text
|
25 |
-
# st.write(code_string)
|
26 |
|
27 |
# Create a fresh module namespace to execute the code in
|
28 |
dynamic_module = types.ModuleType("dynamic_module")
|
29 |
|
30 |
# Execute the code string in the new namespace
|
31 |
exec(code_string, dynamic_module.__dict__)
|
32 |
-
# module = types.ModuleType("dynamic_app")
|
33 |
-
# if hasattr(module,"main"):
|
34 |
-
# module.main()
|
35 |
|
36 |
except requests.exceptions.RequestException as e:
|
37 |
st.error(f"Error downloading the script: {e}")
|
@@ -42,4 +34,4 @@ def execute_remote_script(url: str): # code_str: str
|
|
42 |
if app_url:
|
43 |
execute_remote_script(app_url)
|
44 |
else:
|
45 |
-
st.error("Error loading
|
|
|
1 |
import streamlit as st
|
2 |
import os,types,requests
|
|
|
3 |
|
4 |
# Retrieve your hidden script from the environment variable
|
5 |
app_url = os.environ.get("APP_URL", "")
|
6 |
token = os.environ.get("HF_TOKEN", "")
|
7 |
|
|
|
|
|
|
|
8 |
def execute_remote_script(url: str): # code_str: str
|
9 |
"""
|
10 |
Dynamically compile and execute the provided url string.
|
|
|
18 |
|
19 |
# Get the script content as a string
|
20 |
code_string = response.text
|
|
|
21 |
|
22 |
# Create a fresh module namespace to execute the code in
|
23 |
dynamic_module = types.ModuleType("dynamic_module")
|
24 |
|
25 |
# Execute the code string in the new namespace
|
26 |
exec(code_string, dynamic_module.__dict__)
|
|
|
|
|
|
|
27 |
|
28 |
except requests.exceptions.RequestException as e:
|
29 |
st.error(f"Error downloading the script: {e}")
|
|
|
34 |
if app_url:
|
35 |
execute_remote_script(app_url)
|
36 |
else:
|
37 |
+
st.error("Error loading APP_URL")
|