hatamo commited on
Commit
98a2787
·
1 Parent(s): 718c4ae

Changed loading scripts in app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,12 +1,17 @@
1
  # app.py - Main entry point for Hugging Face Spaces
2
- import sys
3
  import os
 
4
 
5
- # Add code directory to path
6
- sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'code'))
 
 
 
 
 
7
 
8
- # Import and run the FastAPI app
9
- from code.app import app
10
 
11
  if __name__ == "__main__":
12
  import uvicorn
 
1
  # app.py - Main entry point for Hugging Face Spaces
 
2
  import os
3
+ import importlib.util
4
 
5
+ # Load the FastAPI app from code/app.py via importlib to avoid
6
+ # conflicts with the standard-library module named `code`.
7
+ HERE = os.path.dirname(__file__)
8
+ app_path = os.path.join(HERE, "code", "app.py")
9
+ spec = importlib.util.spec_from_file_location("antique_auth_code_app", app_path)
10
+ module = importlib.util.module_from_spec(spec)
11
+ spec.loader.exec_module(module)
12
 
13
+ # The FastAPI `app` object expected inside code/app.py
14
+ app = getattr(module, "app")
15
 
16
  if __name__ == "__main__":
17
  import uvicorn