FastAPI之嵌套依赖注入

from fastapi import Depends


def query(q:Optional[str] = None):
     return q


def sub_query(q: str = Depends(query), last_query: Optionnal[str] = None):
     if not q:
           return q
     return last_query


@app05.get('/sub_dependency')
def sub_dependency(final_query: str = Depends(sub_query, use_cache=True)):
    return {'sub_dependency': final_query}

 

上一篇:docker-compose 解决服务启动完成时间顺序问题


下一篇:odoo13 onchange在wizard窗口中不起作用?