Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,20 +4,17 @@ from pydantic import BaseModel
|
|
| 4 |
import os
|
| 5 |
import importlib
|
| 6 |
|
| 7 |
-
|
| 8 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
print(f"Imported module: {module_name}")
|
| 19 |
-
except Exception as e:
|
| 20 |
-
print(f"Failed to import {module_name}: {e}")
|
| 21 |
|
| 22 |
|
| 23 |
# ---------- FastAPI app ----------
|
|
|
|
| 4 |
import os
|
| 5 |
import importlib
|
| 6 |
|
| 7 |
+
# ---------- Auto-import all .py files in current folder ----------
|
| 8 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 9 |
|
| 10 |
+
for file in os.listdir(current_dir):
|
| 11 |
+
if file.endswith(".py") and file not in ["app.py", "__init__.py"]:
|
| 12 |
+
module_name = file[:-3] # remove '.py'
|
| 13 |
+
try:
|
| 14 |
+
globals()[module_name] = importlib.import_module(module_name)
|
| 15 |
+
print(f"Imported module: {module_name}")
|
| 16 |
+
except Exception as e:
|
| 17 |
+
print(f"Failed to import {module_name}: {e}")
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
# ---------- FastAPI app ----------
|