Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
nsthorat committed Feb 13, 2024
1 parent d28cf90 commit 9f15d12
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lilac/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(self, app: ASGIApp) -> None:
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
"""Redirect trailing slashes to non-trailing slashes."""
url = URL(scope=scope).path
print('url=', url)
root_path = scope.get('root_path')
ends_with_slash = (
url.endswith('/')
Expand All @@ -104,8 +105,10 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
and url != root_path + '/'
and not url.startswith('/api')
)
# ends_with_slash = url.endswith('/') and url != '/' and not url.startswith('/api')

if scope['type'] == 'http' and ends_with_slash:
print('redirectiong to', url.rstrip('/'))
new_url = url.rstrip('/')
response = RedirectResponse(url=new_url, status_code=307)
await response(scope, receive, send)
Expand Down Expand Up @@ -169,15 +172,17 @@ class ServerStatus(BaseModel):
version: str
google_analytics_enabled: bool
disable_error_notifications: bool
root_path: Optional[str]


@app.get('/status')
def status() -> ServerStatus:
def status(request: Request) -> ServerStatus:
"""Returns server status information."""
return ServerStatus(
version=metadata.version('lilac'),
google_analytics_enabled=env('GOOGLE_ANALYTICS_ENABLED', False),
disable_error_notifications=env('LILAC_DISABLE_ERROR_NOTIFICATIONS', False),
root_path=request.scope.get('root_path'),
)


Expand Down
4 changes: 3 additions & 1 deletion run_server_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ if [ "$1" ]; then
else
export LILAC_PROJECT_DIR="./data"
fi
poetry run uvicorn lilac.server:app --reload --port 5432 --host 0.0.0.0 \
# poetry run uvicorn lilac.server:app --reload --port 5432 --host 0.0.0.0 \
# --reload-dir lilac &
poetry run uvicorn integration_tests.fastapi_integration:app --reload --port 5432 --host 0.0.0.0 \
--reload-dir lilac &
pid[1]=$!

Expand Down
1 change: 1 addition & 0 deletions web/blueprint/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// Set the base URL for the OpenAPI requests when the app is served from a subdir.
OpenAPI.BASE = base;
console.log('base=', base);
const routeToPage: Record<string, AppPage> = {
'': 'home',
Expand Down
1 change: 1 addition & 0 deletions web/lib/fastapi_client/models/ServerStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export type ServerStatus = {
version: string;
google_analytics_enabled: boolean;
disable_error_notifications: boolean;
root_path: (string | null);
};

0 comments on commit 9f15d12

Please sign in to comment.