eshan6704 commited on
Commit
0ab582c
·
verified ·
1 Parent(s): a931ad4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -2,17 +2,21 @@ from fastapi import FastAPI, HTTPException
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from pydantic import BaseModel
4
 
5
- # Import all modules from same folder
6
- from stock import *
7
- from indices_html import *
8
- from index_live_html import *
9
- from preopen_html import *
10
- from eq_html import *
11
- from bhavcopy_html import *
12
- from nsepython import *
13
- from yahooinfo import *
14
- from build_nse_fno import *
15
- from common import wrap
 
 
 
 
16
 
17
  app = FastAPI(title="Stock / Index Backend")
18
 
 
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from pydantic import BaseModel
4
 
5
+ import os
6
+ import importlib
7
+
8
+ # ---------- Auto-import all .py files in current folder ----------
9
+ current_dir = os.path.dirname(os.path.abspath(__file__))
10
+
11
+ for file in os.listdir(current_dir):
12
+ if file.endswith(".py") and file not in ["app.py", "__init__.py"]:
13
+ module_name = file[:-3] # remove '.py'
14
+ try:
15
+ globals()[module_name] = importlib.import_module(module_name)
16
+ print(f"Imported module: {module_name}")
17
+ except Exception as e:
18
+ print(f"Failed to import {module_name}: {e}")
19
+
20
 
21
  app = FastAPI(title="Stock / Index Backend")
22