/ justapi / examples / 08_routers.py
swadhinbiswas docs(examples): add 10 progressive tutorial examples and test project · 7/9/2026
b48e461
19 lines · 424 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from justapi import JustAPIApp, APIRouter

app = JustAPIApp()
router = APIRouter(prefix="/api/v1")

@router.get("/users/")
def get_users():
    return [{"username": "alice"}, {"username": "bob"}]

@router.get("/users/{username}")
def get_user(username: str):
    return {"username": username}

# Include the router in the main application
app.include_router(router)

if __name__ == "__main__":
    app.run("127.0.0.1:8000")