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

app = JustAPIApp()

def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
    return {"q": q, "skip": skip, "limit": limit}

@app.get("/items/")
def read_items(commons: dict = Depends(common_parameters)):
    return {"message": "Reading items", "params": commons}

@app.get("/users/")
def read_users(commons: dict = Depends(common_parameters)):
    return {"message": "Reading users", "params": commons}

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