Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -105,13 +105,15 @@ async def root():
|
|
| 105 |
return HTMLResponse(content="<h1>File not found</h1>", status_code=404)
|
| 106 |
|
| 107 |
async def get_models():
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
return
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
|
| 116 |
@app.get("/models")
|
| 117 |
async def fetch_models():
|
|
|
|
| 105 |
return HTMLResponse(content="<h1>File not found</h1>", status_code=404)
|
| 106 |
|
| 107 |
async def get_models():
|
| 108 |
+
try:
|
| 109 |
+
# Load the models from models.json in the same folder
|
| 110 |
+
file_path = Path(__file__).parent / 'models.json'
|
| 111 |
+
with open(file_path, 'r') as f:
|
| 112 |
+
return json.load(f)
|
| 113 |
+
except FileNotFoundError:
|
| 114 |
+
raise HTTPException(status_code=404, detail="models.json not found")
|
| 115 |
+
except json.JSONDecodeError:
|
| 116 |
+
raise HTTPException(status_code=500, detail="Error decoding models.json")
|
| 117 |
|
| 118 |
@app.get("/models")
|
| 119 |
async def fetch_models():
|