sqlalchemy-studio 0.1.5__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/PKG-INFO +1 -1
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/pyproject.toml +1 -1
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio/Studio.py +18 -1
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/PKG-INFO +1 -1
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/README.md +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/setup.cfg +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio/__init__.py +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio/backend.py +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/SOURCES.txt +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/dependency_links.txt +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/requires.txt +0 -0
- {sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from sqlalchemy import and_, create_engine, func, inspect, Engine, or_, select, Table
|
|
2
2
|
from sqlalchemy.engine.interfaces import ReflectedColumn
|
|
3
3
|
from sqlalchemy.orm import DeclarativeBase
|
|
4
|
-
from fastapi import FastAPI, HTTPException, status
|
|
4
|
+
from fastapi import FastAPI, HTTPException, status, Request
|
|
5
5
|
from fastapi.middleware.cors import CORSMiddleware
|
|
6
6
|
from fastapi.staticfiles import StaticFiles
|
|
7
7
|
from importlib.resources import files
|
|
8
|
+
from fastapi.responses import FileResponse
|
|
9
|
+
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
8
10
|
import uvicorn
|
|
9
11
|
|
|
10
12
|
|
|
@@ -78,6 +80,21 @@ class Studio:
|
|
|
78
80
|
StaticFiles(directory=str(static_dir), html=True),
|
|
79
81
|
name="static",
|
|
80
82
|
)
|
|
83
|
+
# SPA fallback: return index.html for any non-API path so client-side
|
|
84
|
+
# routing (e.g. /tables/users) works. Keep API routes handled above.
|
|
85
|
+
index_file = static_dir.joinpath("index.html")
|
|
86
|
+
if index_file.exists():
|
|
87
|
+
|
|
88
|
+
async def spa_404_handler(
|
|
89
|
+
request: Request, exc: StarletteHTTPException
|
|
90
|
+
):
|
|
91
|
+
if exc.status_code == 404 and not request.url.path.startswith(
|
|
92
|
+
"/api"
|
|
93
|
+
):
|
|
94
|
+
return FileResponse(str(index_file))
|
|
95
|
+
raise exc
|
|
96
|
+
|
|
97
|
+
self.app.add_exception_handler(StarletteHTTPException, spa_404_handler)
|
|
81
98
|
|
|
82
99
|
def run(self, port: int = 8000):
|
|
83
100
|
print("-" * 50)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{sqlalchemy_studio-0.1.5 → sqlalchemy_studio-0.1.6}/sqlalchemy_studio.egg-info/top_level.txt
RENAMED
|
File without changes
|