Skip to content

Commit d496553

Browse files
committed
chore(python): move routes to routes.py file
See https://fastapi.tiangolo.com/tutorial/bigger-applications/ Part of #16
1 parent 96678e0 commit d496553

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Generates the endpoints (or a whole app) from a mapping (SQL query -> URL)
4848
| -----------| ----------------------------| ---------------------------| --------- |
4949
| JavaScript | `npx query2app --lang js` | [`app.js`](examples/js/app.js)<br/>[`routes.js`](examples/js/routes.js)<br/>[`package.json`](examples/js/package.json) | Web: [`express`](https://www.npmjs.com/package/express), [`body-parser`](https://www.npmjs.com/package/body-parser)<br>Database: [`mysql`](https://www.npmjs.com/package/mysql) |
5050
| Golang | `npx query2app --lang go` | [`app.go`](examples/go/app.go)<br/>[`routes.go`](examples/go/routes.go)<br/>[`go.mod`](examples/go/go.mod) | Web: [`go-chi/chi`](https://github.com/go-chi/chi)<br/>Database: [`go-sql-driver/mysql`](https://github.com/go-sql-driver/mysql), [`jmoiron/sqlx`](https://github.com/jmoiron/sqlx) |
51-
| Python | `npx query2app --lang python` | [`app.py`](examples/python/app.py), [`requirements.txt`](examples/python/requirements.txt) | Web: [FastAPI](https://github.com/tiangolo/fastapi), [Uvicorn](https://www.uvicorn.org) |
51+
| Python | `npx query2app --lang python` | [`app.py`](examples/python/app.py), [`routes.py`](examples/python/routes.py), [`requirements.txt`](examples/python/requirements.txt) | Web: [FastAPI](https://github.com/tiangolo/fastapi), [Uvicorn](https://www.uvicorn.org) |
5252

5353
1. Run the application
5454
| Language | Commands to run the application |

examples/python/app.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from fastapi import FastAPI
2+
from routes import router
23

34
app = FastAPI()
45

5-
@app.get('/')
6-
def home():
7-
return { "hello": "world" }
6+
app.include_router(router)

examples/python/routes.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from fastapi import APIRouter
2+
3+
router = APIRouter()
4+
5+
@router.get('/')
6+
def home():
7+
return { "hello": "world" }

src/templates/app.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from fastapi import FastAPI
2+
from routes import router
23

34
app = FastAPI()
45

5-
@app.get('/')
6-
def home():
7-
return { "hello": "world" }
6+
app.include_router(router)

src/templates/routes.py.ejs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from fastapi import APIRouter
2+
3+
router = APIRouter()
4+
5+
@router.get('/')
6+
def home():
7+
return { "hello": "world" }

0 commit comments

Comments
 (0)