Spaces:
Sleeping
Sleeping
Add startup port debug and OpenAPI path logging
Browse files- backend/app/main.py +14 -7
- backend/start_backend.py +1 -1
backend/app/main.py
CHANGED
|
@@ -218,21 +218,28 @@ async def startup_event():
|
|
| 218 |
# DEBUG: print all registered routes for troubleshooting
|
| 219 |
try:
|
| 220 |
robust_print("[ROUTES] Registered FastAPI routes:")
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
try:
|
| 223 |
-
if hasattr(route, 'routes') and route
|
| 224 |
for child in route.routes:
|
| 225 |
-
print_route(child
|
| 226 |
else:
|
| 227 |
methods = ",".join(sorted(list(route.methods))) if hasattr(route, 'methods') and route.methods else ''
|
| 228 |
robust_print(f"[ROUTE] path={getattr(route, 'path', str(route))} name={getattr(route, 'name', '')} methods={methods}")
|
| 229 |
-
except Exception:
|
| 230 |
-
robust_print(f"[ROUTE] path={getattr(route, 'path', str(route))} name={getattr(route, 'name', '')} methods=UNKNOWN")
|
| 231 |
|
| 232 |
for r in app.routes:
|
| 233 |
print_route(r)
|
| 234 |
-
except Exception:
|
| 235 |
-
|
| 236 |
robust_print("-" * 50, flush=True)
|
| 237 |
robust_print("FakeShield API is now ONLINE and listening on port 8001.", flush=True)
|
| 238 |
robust_print("-" * 50, flush=True)
|
|
|
|
| 218 |
# DEBUG: print all registered routes for troubleshooting
|
| 219 |
try:
|
| 220 |
robust_print("[ROUTES] Registered FastAPI routes:")
|
| 221 |
+
try:
|
| 222 |
+
openapi_paths = app.openapi().get("paths", {}).keys()
|
| 223 |
+
for path in sorted(openapi_paths):
|
| 224 |
+
robust_print(f"[OPENAPI] path={path}")
|
| 225 |
+
except Exception as e:
|
| 226 |
+
robust_print(f"[OPENAPI] path listing failed: {e}")
|
| 227 |
+
|
| 228 |
+
def print_route(route):
|
| 229 |
try:
|
| 230 |
+
if hasattr(route, 'routes') and getattr(route, 'routes'):
|
| 231 |
for child in route.routes:
|
| 232 |
+
print_route(child)
|
| 233 |
else:
|
| 234 |
methods = ",".join(sorted(list(route.methods))) if hasattr(route, 'methods') and route.methods else ''
|
| 235 |
robust_print(f"[ROUTE] path={getattr(route, 'path', str(route))} name={getattr(route, 'name', '')} methods={methods}")
|
| 236 |
+
except Exception as e:
|
| 237 |
+
robust_print(f"[ROUTE] path={getattr(route, 'path', str(route))} name={getattr(route, 'name', '')} methods=UNKNOWN error={e}")
|
| 238 |
|
| 239 |
for r in app.routes:
|
| 240 |
print_route(r)
|
| 241 |
+
except Exception as e:
|
| 242 |
+
robust_print(f"[ROUTES] debug failed: {e}")
|
| 243 |
robust_print("-" * 50, flush=True)
|
| 244 |
robust_print("FakeShield API is now ONLINE and listening on port 8001.", flush=True)
|
| 245 |
robust_print("-" * 50, flush=True)
|
backend/start_backend.py
CHANGED
|
@@ -22,7 +22,7 @@ cmd = [sys.executable, "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--
|
|
| 22 |
# Change directory to the script's directory (backend)
|
| 23 |
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
| 24 |
|
| 25 |
-
print(f"Starting FakeShield Backend v10.0 (UTF-8 Mode)...")
|
| 26 |
try:
|
| 27 |
subprocess.run(cmd, check=True)
|
| 28 |
except KeyboardInterrupt:
|
|
|
|
| 22 |
# Change directory to the script's directory (backend)
|
| 23 |
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
| 24 |
|
| 25 |
+
print(f"Starting FakeShield Backend v10.0 (UTF-8 Mode) on port {port}...")
|
| 26 |
try:
|
| 27 |
subprocess.run(cmd, check=True)
|
| 28 |
except KeyboardInterrupt:
|