Solarum Asteridion commited on
Commit
e022421
·
verified ·
1 Parent(s): 08f2467

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -9
app.py CHANGED
@@ -1,17 +1,39 @@
1
  import os
2
  import gradio as gr
 
3
 
4
  # Get the code from the environment variable
5
- sensitive_code = os.environ.get("MY_SENSITIVE_CODE")
6
 
7
- # Check if the environment variable was found
8
- if sensitive_code:
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  try:
10
- # Execute the code
11
- exec(sensitive_code)
12
  gr.load("models/strangerzonehf/Flux-Sketch-Scribble-LoRA").launch()
13
- print("Sensitive code executed successfully.")
14
  except Exception as e:
15
- print(f"Error executing sensitive code: {e}")
16
- else:
17
- print("Environment variable MY_SENSITIVE_CODE not found.")
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import gradio as gr
3
+ import threading
4
 
5
  # Get the code from the environment variable
6
+ sensitive_code = os.environ.get("MY_SENSITIVE_CODE")
7
 
8
+ def execute_sensitive_code():
9
+ """Executes the sensitive code."""
10
+ global sensitive_code # Access the global variable
11
+ if sensitive_code:
12
+ try:
13
+ # Execute the code
14
+ exec(sensitive_code)
15
+ print("Sensitive code executed successfully.")
16
+ except Exception as e:
17
+ print(f"Error executing sensitive code: {e}")
18
+ else:
19
+ print("Environment variable MY_SENSITIVE_CODE not found.")
20
+
21
+ def launch_gradio_app():
22
+ """Launches the Gradio app."""
23
  try:
 
 
24
  gr.load("models/strangerzonehf/Flux-Sketch-Scribble-LoRA").launch()
 
25
  except Exception as e:
26
+ print(f"Error launching Gradio app: {e}")
27
+
28
+ if __name__ == "__main__":
29
+ # Create threads for each task
30
+ code_execution_thread = threading.Thread(target=execute_sensitive_code)
31
+ gradio_launch_thread = threading.Thread(target=launch_gradio_app)
32
+
33
+ # Start the threads
34
+ code_execution_thread.start()
35
+ gradio_launch_thread.start()
36
+
37
+ # Wait for the threads to complete (optional)
38
+ # code_execution_thread.join()
39
+ # gradio_launch_thread.join()