forked from liaogx/fastapi-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter07.py
More file actions
26 lines (17 loc) · 769 Bytes
/
chapter07.py
File metadata and controls
26 lines (17 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ = '__Jack__'
from fastapi import APIRouter, Depends, Request
"""【见coronavirus应用】SQL (Relational) Databases FastAPI的数据库操作"""
"""Bigger Applications - Multiple Files 多应用的目录结构设计"""
async def get_user_agent(request: Request):
print(request.headers["User-Agent"])
app07 = APIRouter(
prefix="/bigger_applications",
tags=["第七章 FastAPI的数据库操作和多应用的目录结构设计"], # 与run.py中的tags名称相同
dependencies=[Depends(get_user_agent)],
responses={200: {"description": "Good job!"}},
)
@app07.get("/bigger_applications")
async def bigger_applications():
return {"message": "Bigger Applications - Multiple Files"}