当前位置:首页>python>Python Web开发:FastAPI基础

Python Web开发:FastAPI基础

  • 2026-07-02 16:33:00
Python Web开发:FastAPI基础
副标题

: 90%的人不知道,FastAPI的性能比Flask快300倍

痛点:为什么你的Web API开发总是很慢?

2025年某团队用Flask开发API,响应时间平均500ms。问题出在哪?工程师没有使用现代异步框架。

真相

:FastAPI基于Starlette和Pydantic,性能接近NodeJS和Go。

框架性能学习曲线推荐度
Flask1x⭐⭐⭐
Django0.5x⭐⭐⭐
FastAPI3-5x⭐⭐⭐⭐⭐
Sanic4x⭐⭐⭐⭐

一、FastAPI基础

1.1 第一个应用

from fastapi import FastAPI

app = FastAPI(

title="我的API",

description="一个FastAPI示例项目",

version="1.0.0"

)

@app.get("/")

async def root():

return {"message": "Hello, World!"}

@app.get("/items/{item_id}")

async def read_item(item_id: int):

return {"item_id": item_id}

# 运行

uvicorn main:app --reload

访问自动文档

http://localhost:8000/docs # Swagger UI

http://localhost:8000/redoc # ReDoc

1.2 路径操作

from fastapi import FastAPI

app = FastAPI()

GET

@app.get("/items/{item_id}")

async def get_item(item_id: int):

return {"item_id": item_id}

POST

@app.post("/items/")

async def create_item(name: str, price: float):

return {"name": name, "price": price}

PUT

@app.put("/items/{item_id}")

async def update_item(item_id: int, name: str):

return {"item_id": item_id, "name": name}

DELETE

@app.delete("/items/{item_id}")

async def delete_item(item_id: int):

return {"item_id": item_id, "message": "Deleted"}

带查询参数

@app.get("/search")

async def search(q: str, limit: int = 10, skip: int = 0):

return {"q": q, "limit": limit, "skip": skip}

1.3 请求体

from fastapi import FastAPI

from pydantic import BaseModel

app = FastAPI()

class Item(BaseModel):

name: str

price: float

description: str | None = None

tags: list[str] = []

@app.post("/items/")

async def create_item(item: Item):

return item

@app.put("/items/{item_id}")

async def update_item(item_id: int, item: Item):

return {"item_id": item_id, **item.model_dump()}

二、路径参数

2.1 基础路径参数

from fastapi import FastAPI

app = FastAPI()

@app.get("/users/{user_id}")

async def read_user(user_id: str):

return {"user_id": user_id}

@app.get("/items/{item_id}")

async def read_item(item_id: int):

return {"item_id": item_id}

2.2 路径参数验证

from fastapi import FastAPI, Path

from typing import Annotated

app = FastAPI()

@app.get("/items/{item_id}")

async def read_item(

item_id: Annotated[int, Path(title="物品ID", ge=0, le=1000)]

):

return {"item_id": item_id}

@app.get("/users/{user_id}")

async def read_user(

user_id: Annotated[str, Path(min_length=3, max_length=50, pattern=r"^[a-zA-Z0-9_-]+$")]

):

return {"user_id": user_id}

2.3 多个路径参数

@app.get("/users/{user_id}/items/{item_id}")

async def read_user_item(

user_id: str,

item_id: int,

q: str | None = None,

short: bool = False

):

item = {"item_id": item_id, "owner_id": user_id}

if q:

item.update({"q": q})

if short:

item = {"item_id": item_id, "owner_id": user_id}

return item

三、查询参数

3.1 基础查询参数

from fastapi import FastAPI

app = FastAPI()

@app.get("/items/")

async def read_items(

q: str | None = None,

skip: int = 0,

limit: int = 100

):

return {"q": q, "skip": skip, "limit": limit}

3.2 查询参数验证

from fastapi import FastAPI, Query

from typing import Annotated

app = FastAPI()

@app.get("/items/")

async def read_items(

q: Annotated[str | None, Query(min_length=3, max_length=50)] = None,

skip: Annotated[int, Query(ge=0)] = 0,

limit: Annotated[int, Query(ge=1, le=100)] = 100

):

return {"q": q, "skip": skip, "limit": limit}

3.3 列表查询参数

@app.get("/items/")

async def read_items(

q: list[str] | None = None,

skip: int = 0,

limit: int = 100

):

return {"q": q, "skip": skip, "limit": limit}

访问: /items/?q=foo&q=bar&q=baz

四、请求体与字段验证

4.1 Pydantic模型

from fastapi import FastAPI

from pydantic import BaseModel, Field, field_validator

from typing import Annotated

app = FastAPI()

class Item(BaseModel):

name: Annotated[str, Field(min_length=1, max_length=50)]

price: Annotated[float, Field(gt=0)]

description: str | None = Field(None, max_length=500)

tags: list[str] = Field(default_factory=list)

in_stock: bool = True

@field_validator('name')

@classmethod

def validate_name(cls, v: str) -> str:

if not v.strip():

raise ValueError('名称不能为空')

return v.strip()

@app.post("/items/")

async def create_item(item: Item):

return item

4.2 嵌套模型

class Address(BaseModel):

street: str

city: str

zip_code: str

class User(BaseModel):

username: str

email: str

address: Address | None = None

@app.post("/users/")

async def create_user(user: User):

return user

4.3 多个请求体

from fastapi import FastAPI, Body

from pydantic import BaseModel

app = FastAPI()

class Item(BaseModel):

name: str

price: float

@app.put("/items/{item_id}")

async def update_item(

item_id: int,

item: Item,

q: str | None = None,

importance: int = Body(1, ge=1, le=5),

include_in_memory: bool = Body(False)

):

return {

"item_id": item_id,

"item": item,

"q": q,

"importance": importance,

"include_in_memory": include_in_memory

}

五、响应模型

5.1 响应模型过滤

from fastapi import FastAPI

from pydantic import BaseModel, SecretStr

app = FastAPI()

class UserIn(BaseModel):

username: str

password: SecretStr

email: str

full_name: str | None = None

class UserOut(BaseModel):

username: str

email: str

full_name: str | None = None

@app.post("/users/", response_model=UserOut)

async def create_user(user: UserIn):

# password不会被返回

return user

5.2 响应状态码

from fastapi import FastAPI, status

app = FastAPI()

@app.post("/items/", status_code=status.HTTP_201_CREATED)

async def create_item(item: dict):

return item

@app.delete("/items/{item_id}", status_code=status.HTTP_204_NO_CONTENT)

async def delete_item(item_id: int):

return None

5.3 自定义响应

from fastapi import FastAPI

from fastapi.responses import JSONResponse, RedirectResponse

app = FastAPI()

@app.get("/redirect")

async def redirect_example():

return RedirectResponse(url="/items/")

@app.get("/custom")

async def custom_response():

return JSONResponse(

content={"message": "Custom response"},

status_code=200,

headers={"X-Custom-Header": "value"}

)

六、依赖注入

6.1 基础依赖

from fastapi import FastAPI, Depends

app = FastAPI()

async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):

return {"q": q, "skip": skip, "limit": limit}

@app.get("/items/")

async def read_items(commons: dict = Depends(common_parameters)):

return commons

@app.get("/users/")

async def read_users(commons: dict = Depends(common_parameters)):

return commons

6.2 类依赖

from fastapi import FastAPI, Depends, HTTPException

app = FastAPI()

class CommonQueryParams:

def __init__(self, q: str | None = None, skip: int = 0, limit: int = 100):

self.q = q

self.skip = skip

self.limit = limit

@app.get("/items/")

async def read_items(commons: CommonQueryParams = Depends()):

return {

"q": commons.q,

"skip": commons.skip,

"limit": commons.limit

}

6.3 认证依赖

from fastapi import FastAPI, Depends, HTTPException, status

from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials

app = FastAPI()

security = HTTPBearer()

async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(security)):

token = credentials.credentials

# 验证token

if token != "valid-token":

raise HTTPException(

status_code=status.HTTP_401_UNAUTHORIZED,

detail="Invalid token"

)

return {"user_id": "user123", "token": token}

@app.get("/users/me")

async def read_users_me(current_user: dict = Depends(get_current_user)):

return current_user

6.4 依赖树

async def query_dependency(q: str | None = None):

return {"q": q}

async def pagination_dependency(skip: int = 0, limit: int = 100):

return {"skip": skip, "limit": limit}

async def common_dependency(

q_data: dict = Depends(query_dependency),

page_data: dict = Depends(pagination_dependency)

):

return {q_data, page_data}

@app.get("/items/")

async def read_items(commons: dict = Depends(common_dependency)):

return commons

七、错误处理

7.1 HTTPException

from fastapi import FastAPI, HTTPException, status

app = FastAPI()

items = {"foo": "bar"}

@app.get("/items/{item_id}")

async def read_item(item_id: str):

if item_id not in items:

raise HTTPException(

status_code=status.HTTP_404_NOT_FOUND,

detail=f"Item {item_id} not found",

headers={"X-Error": "Item not found"}

)

return {"item": items[item_id]}

7.2 自定义异常处理器

from fastapi import FastAPI, Request

from fastapi.responses import JSONResponse

app = FastAPI()

class ItemNotFoundError(Exception):

def __init__(self, item_id: str):

self.item_id = item_id

@app.exception_handler(ItemNotFoundError)

async def item_not_found_handler(request: Request, exc: ItemNotFoundError):

return JSONResponse(

status_code=404,

content={"message": f"Item {exc.item_id} not found"}

)

@app.get("/items/{item_id}")

async def read_item(item_id: str):

if item_id not in items:

raise ItemNotFoundError(item_id)

return {"item": items[item_id]}

7.3 全局异常处理

@app.exception_handler(Exception)

async def global_exception_handler(request: Request, exc: Exception):

return JSONResponse(

status_code=500,

content={

"message": "Internal server error",

"detail": str(exc) if app.debug else None

}

)

八、中间件

8.1 基础中间件

from fastapi import FastAPI, Request

import time

app = FastAPI()

@app.middleware("http")

async def add_process_time_header(request: Request, call_next):

start_time = time.time()

response = await call_next(request)

process_time = time.time() - start_time

response.headers["X-Process-Time"] = str(process_time)

return response

8.2 CORS中间件

from fastapi import FastAPI

from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(

CORSMiddleware,

allow_origins=["*"],

allow_credentials=True,

allow_methods=["*"],

allow_headers=["*"],

)

8.3 日志中间件

import logging

from fastapi import FastAPI, Request

logger = logging.getLogger("uvicorn")

@app.middleware("http")

async def log_requests(request: Request, call_next):

start_time = time.time()

response = await call_next(request)

process_time = time.time() - start_time

logger.info(

f"{request.method} {request.url.path} - {response.status_code} - {process_time:.3f}s"

)

return response

九、实战案例

9.1 完整API项目结构

my_api/

├── app/

│ ├── __init__.py

│ ├── main.py

│ ├── config.py

│ ├── database.py

│ ├── models.py

│ ├── schemas.py

│ ├── api/

│ │ ├── __init__.py

│ │ ├── v1/

│ │ │ ├── __init__.py

│ │ │ ├── items.py

│ │ │ └── users.py

│ │ └── deps.py

│ └── core/

│ ├── __init__.py

│ ├── security.py

│ └── exceptions.py

├── tests/

│ ├── __init__.py

│ ├── test_items.py

│ └── test_users.py

├── .env

├── pyproject.toml

└── README.md

9.2 用户管理系统

# app/schemas.py

from pydantic import BaseModel, EmailStr, Field

from datetime import datetime

from typing import Annotated

class UserBase(BaseModel):

email: EmailStr

username: Annotated[str, Field(min_length=3, max_length=50)]

class UserCreate(UserBase):

password: Annotated[str, Field(min_length=8)]

class User(UserBase):

id: int

is_active: bool = True

created_at: datetime

class ItemBase(BaseModel):

name: str

description: str | None = None

price: float

class ItemCreate(ItemBase):

pass

class Item(ItemBase):

id: int

owner_id: int

created_at: datetime

# app/api/v1/items.py

from fastapi import APIRouter, Depends, HTTPException, status

from typing import Annotated

from app.schemas import Item, ItemCreate

from app.api import deps

router = APIRouter()

@router.post("/", response_model=Item, status_code=status.HTTP_201_CREATED)

async def create_item(

item_in: ItemCreate,

current_user: dict = Depends(deps.get_current_user)

):

return item_in

@router.get("/", response_model=list[Item])

async def read_items(

skip: int = 0,

limit: int = 100,

current_user: dict = Depends(deps.get_current_user)

):

return []

@router.get("/{item_id}", response_model=Item)

async def read_item(

item_id: int,

current_user: dict = Depends(deps.get_current_user)

):

return {"id": item_id, "name": "test"}

@router.delete("/{item_id}", status_code=status.HTTP_204_NO_CONTENT)

async def delete_item(

item_id: int,

current_user: dict = Depends(deps.get_current_user)

):

return None

# app/main.py

from fastapi import FastAPI

from app.api.v1 import items, users

from app.core.config import settings

app = FastAPI(

title=settings.APP_NAME,

version="1.0.0"

)

app.include_router(items.router, prefix="/api/v1/items", tags=["items"])

app.include_router(users.router, prefix="/api/v1/users", tags=["users"])

@app.get("/health")

async def health_check():

return {"status": "healthy"}

十、测试

10.1 单元测试

from fastapi.testclient import TestClient

from app.main import app

client = TestClient(app)

def test_read_main():

response = client.get("/")

assert response.status_code == 200

assert response.json() == {"message": "Hello, World!"}

def test_create_item():

response = client.post(

"/items/",

json={"name": "foo", "price": 10.5}

)

assert response.status_code == 201

data = response.json()

assert data["name"] == "foo"

assert data["price"] == 10.5

def test_read_item_not_found():

response = client.get("/items/999")

assert response.status_code == 404

10.2 依赖覆盖测试

from fastapi import Depends

from app.main import app

from app.api import deps

def override_get_current_user():

return {"user_id": "test_user", "is_admin": True}

app.dependency_overrides[deps.get_current_user] = override_get_current_user

def test_admin_endpoint():

response = client.get("/admin/users")

assert response.status_code == 200

app.dependency_overrides.clear()

常见坑自查清单

现象自查方法修复方案
类型错误422错误检查Pydantic模型添加类型注解
依赖未注入None值检查Depends使用正确使用Depends
异步阻塞性能差检查async/await使用async函数
循环依赖导入错误检查模块结构重构代码结构

结语

关键洞察

  • FastAPI性能优秀,基于异步
  • Pydantic提供强大的数据验证
  • 依赖注入系统灵活强大
  • 自动生成API文档

互动

  1. 1.你用FastAPI开发过什么项目?
  2. 2.依赖注入好用吗?
  3. 3.遇到过性能问题吗?
版本: V1.0 | 2026-05-26 | Python Web开发系列

📚 推荐阅读

📝 摘要:今天深入学习静态代码分析技术,这是安全审计的核心技能。从 Python AST 模块到检测模式设计,收获满满!

发布于 202603

01-Python 环境搭建与第一个脚本

发布于 202603

【优化】Python代码优化与调试技巧

发布于 202603

KEYWORDS

IL, Python, AI, 函数, 循环

💡 如果你觉得这篇文章有帮助,请点个在看,分享给更多需要的人!

📝 关注我,获取更多实用干货~

🤝 有问题欢迎评论区留言交流!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 09:31:52 HTTP/2.0 GET : https://f.mffb.com.cn/a/495674.html
  2. 运行时间 : 0.152469s [ 吞吐率:6.56req/s ] 内存消耗:4,387.95kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f610ca36ef8f3f8ff052ab3d009bd415
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000624s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000847s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000428s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000267s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000503s ]
  6. SELECT * FROM `set` [ RunTime:0.000207s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000523s ]
  8. SELECT * FROM `article` WHERE `id` = 495674 LIMIT 1 [ RunTime:0.000465s ]
  9. UPDATE `article` SET `lasttime` = 1783042312 WHERE `id` = 495674 [ RunTime:0.024363s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000409s ]
  11. SELECT * FROM `article` WHERE `id` < 495674 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.004873s ]
  12. SELECT * FROM `article` WHERE `id` > 495674 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.004590s ]
  13. SELECT * FROM `article` WHERE `id` < 495674 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.005392s ]
  14. SELECT * FROM `article` WHERE `id` < 495674 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.023667s ]
  15. SELECT * FROM `article` WHERE `id` < 495674 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.017168s ]
0.154147s