Spaces:
Running
Running
File size: 838 Bytes
ad807d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import os
import sys
import importlib.util
# Name of the environment variable
ENV_VAR = "GRADIO_APP_PATH"
def main():
app_path = os.getenv(ENV_VAR)
if not app_path:
print(f"❌ Error: Environment variable '{ENV_VAR}' is not set.")
sys.exit(1)
if not os.path.isfile(app_path):
print(f"❌ Error: File at '{app_path}' does not exist.")
sys.exit(1)
# Dynamically import the module
spec = importlib.util.spec_from_file_location("gradio_app", app_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
# Launch the Gradio interface
if hasattr(module, "launch"):
module.launch()
else:
print("❌ Error: The specified file does not have a 'launch()' function.")
sys.exit(1)
if __name__ == "__main__":
main()
|