Skip to content

Commit 0503375

Browse files
committed
fastapi examples
1 parent cef63e4 commit 0503375

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

examples/demo_fastapi.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
"""
5-
FastAPI port of examples/demo_pythonanywhere_com.py.
4+
FastAPI Example
65
76
Run:
7+
pip install safrs
88
python examples/demo_fastapi.py [HOST] [PORT]
99
1010
Then open:
@@ -35,8 +35,7 @@
3535

3636
description = """
3737
<a href=http://jsonapi.org>Json:API</a> compliant API built with https://github.com/thomaxxl/safrs <br/>
38-
- <a href="https://github.com/thomaxxl/safrs/blob/master/examples/demo_fastapi.py">Source code of this page</a><br/>
39-
- <a href="/ja/">reactjs+redux frontend</a>
38+
<a href="https://github.com/thomaxxl/safrs/blob/master/examples/demo_fastapi.py">Source code of this page</a><br/>
4039
"""
4140

4241
Base = declarative_base()
@@ -249,7 +248,7 @@ async def safrs_session_middleware(request: Any, call_next: Any) -> Any:
249248

250249
@app.get("/", include_in_schema=False)
251250
def root() -> Any:
252-
return RedirectResponse(url=API_PREFIX)
251+
return RedirectResponse(url="/docs/")
253252

254253
@app.get("/health", include_in_schema=False)
255254
def health() -> dict[str, Any]:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VITE_API_ROOT=http://127.0.0.1:5001/api
2-
VITE_ADMIN_YAML_URL=http://127.0.0.1:5001/ui/admin/admin.yaml
1+
VITE_API_ROOT=/api
2+
VITE_ADMIN_YAML_URL=/ui/admin/admin.yaml
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const appConfig = {
22
adminYamlUrl:
33
import.meta.env.VITE_ADMIN_YAML_URL
4-
?? "http://127.0.0.1:5656/ui/admin/admin.yaml",
5-
apiRoot: import.meta.env.VITE_API_ROOT ?? "http://127.0.0.1:5656/api",
4+
?? "/ui/admin/admin.yaml",
5+
apiRoot: import.meta.env.VITE_API_ROOT ?? "/api",
66
title: "Northwind Admin",
77
} as const;

0 commit comments

Comments
 (0)