python 3.x - Dependence injection in FastHTML? - Stack Overflow

admin2025-04-22  5

In "fastapi" you can use "Depends" in a endpoint:

from fastapi import Depends

@app.get("/depends_test")
def getdbtest(request, db: Session = Depends(get_db) ):
    return db.query(Token).all()

Is there any "Depends" equivalent in FastHTML?

In "fastapi" you can use "Depends" in a endpoint:

from fastapi import Depends

@app.get("/depends_test")
def getdbtest(request, db: Session = Depends(get_db) ):
    return db.query(Token).all()

Is there any "Depends" equivalent in FastHTML?

Share Improve this question asked Jan 21 at 14:31 Ximo DanteXimo Dante 12511 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Looks like it is not a feature on fastHTML but a discussed topic. This issue on github offers a solution github. But since fastapi and fastHTML are focusing on diffrent logics there are diffrent tools included.

转载请注明原文地址:http://www.anycun.com/QandA/1745304482a90627.html