当前位置:首页>python>FastAPI 入门:Python 现代 Web 框架

FastAPI 入门:Python 现代 Web 框架

  • 2026-03-27 07:49:54
FastAPI 入门:Python 现代 Web 框架
FastAPI 入门:Python 现代 Web 框架
引言

在 Python Web 开发的世界里,FastAPI 正如一颗新星冉冉升起。它以惊人的速度、简洁的语法和强大的自动文档功能,迅速赢得了开发者的青睐。本文将带你从零开始学习 FastAPI,掌握这个现代 Web 框架的核心特性和实战技巧。

什么是 FastAPI?

FastAPI 是一个现代、高性能的 Web 框架,用于使用 Python 3.8+ 构建 API。它基于标准 Python 类型提示,具有以下核心优势:

核心特性
  • 🚀 极速性能 - 基于 Starlette 和 Pydantic,性能媲美 NodeJS 和 Go
  • 📝 自动文档 - 自动生成 OpenAPI 和 ReDoc 文档
  • ✅ 类型检查 - 基于 Python 类型提示,自动验证数据
  • 🎯 智能提示 - IDE 自动补全,开发体验极佳
  • 🔒 数据验证 - 自动验证请求数据,返回清晰错误
  • 🌐 异步支持 - 原生支持 async/await 异步编程
与其他框架对比
特性
Flask
Django REST
FastAPI
性能
中等
较慢
⭐ 极快
异步支持
有限
有限
⭐ 原生
自动文档
需插件
⭐ 内置
数据验证
手动
手动
⭐ 自动
类型安全
⭐ 完整
学习曲线
⭐ 低
快速开始
环境要求
  • Python 3.8 或更高版本
  • pip 或 uv 包管理器
安装 FastAPI
1# 使用 pip 安装2pip install fastapi uvicorn[standard]34# 或使用 uv(推荐)5uv add fastapi uvicorn[standard]

依赖说明:

  • fastapi
     - Web 框架核心
  • uvicorn
     - ASGI 服务器,用于运行应用
第一个 FastAPI 应用

创建 main.py

1from fastapi import FastAPI23app = FastAPI()45@app.get("/")6async def root():7    return {"message": "Hello World"}89@app.get("/items/{item_id}")10async def read_item(item_id: int):11    return {"item_id": item_id}

运行应用:

1uvicorn main:app --reload23# 访问 http://127.0.0.1:8000

参数说明:

  • main:app
     - main.py 文件中的 app 对象
  • --reload
     - 开发模式,自动重载代码
查看自动文档

FastAPI 自动生成两种交互式文档:

  1. Swagger UI
     - http://127.0.0.1:8000/docs
  2. ReDoc
     - http://127.0.0.1:8000/redoc

打开浏览器访问,即可看到完整的 API 文档和测试界面!

核心概念详解
1. 路径操作装饰器

FastAPI 使用装饰器定义路由:

1from fastapi import FastAPI23app = FastAPI()45@app.get("/users")           # GET 请求6async def get_users():7    return {"method": "GET"}89@app.post("/users")          # POST 请求10async def create_user():11    return {"method": "POST"}1213@app.put("/users/{id}")      # PUT 请求14async def update_user(id: int):15    return {"method": "PUT", "id": id}1617@app.delete("/users/{id}")   # DELETE 请求18async def delete_user(id: int):19    return {"method": "DELETE", "id": id}2021@app.patch("/users/{id}")    # PATCH 请求22async def patch_user(id: int):23    return {"method": "PATCH", "id": id}
2. 路径参数
1from fastapi import FastAPI23app = FastAPI()45@app.get("/users/{user_id}")6async def get_user(user_id: int):7    """获取用户信息"""8    return {"user_id": user_id}910@app.get("/users/{user_id}/posts/{post_id}")11async def get_user_post(user_id: int, post_id: int):12    """获取用户的文章"""13    return {"user_id": user_id, "post_id": post_id}1415# 路径参数类型转换16@app.get("/files/{file_path:path}")17async def read_file(file_path: str):18    """读取文件路径(包含斜杠)"""19    return {"file_path": file_path}

类型验证:

  • int
     - 自动转换为整数,错误时返回清晰提示
  • str
     - 字符串
  • float
     - 浮点数
  • bool
     - 布尔值
  • path
     - 包含斜杠的路径
3. 查询参数
1from fastapi import FastAPI2from typing import Optional34app = FastAPI()56@app.get("/items")7async def read_items(8    skip: int = 0,           # 默认值9    limit: int = 10,10    search: Optional[str] = None  # 可选参数11):12    """获取物品列表"""13    return {14        "skip": skip,15        "limit": limit,16        "search": search17    }1819# 访问:/items?skip=5&limit=20&search=python

查询参数特性:

  • 自动从 URL 查询字符串提取
  • 支持默认值
  • 支持可选参数
  • 自动类型验证
4. 请求体和 Pydantic 模型
1from fastapi import FastAPI2from pydantic import BaseModel, EmailStr, Field34app = FastAPI()56# 定义数据模型7class UserCreate(BaseModel):8    username: str = Field(..., min_length=3, max_length=50)9    email: EmailStr10    password: str = Field(..., min_length=8)11    full_name: Optional[str] = None12    is_active: bool = True1314class UserResponse(BaseModel):15    id: int16    username: str17    email: EmailStr18    full_name: Optional[str]1920    class Config:21        from_attributes = True2223@app.post("/users", response_model=UserResponse)24async def create_user(user: UserCreate):25    """创建用户"""26    # user 自动验证和解析27    return {28        "id": 1,29        "username": user.username,30        "email": user.email,31        "full_name": user.full_name32    }

Pydantic 验证器:

1from pydantic import BaseModel, validator, Field23class Product(BaseModel):4    name: str5    price: float = Field(..., gt=0)  # 必须大于 06    quantity: int = Field(default=1, ge=0)  # 必须大于等于 078    @validator(&#x27;name&#x27;)9    def name_must_not_be_empty(cls, v):10        if not v.strip():11            raise ValueError(&#x27;名称不能为空&#x27;)12        return v.strip()1314    @validator(&#x27;price&#x27;)15    def price_must_be_positive(cls, v):16        if v <= 0:17            raise ValueError(&#x27;价格必须大于 0&#x27;)18        return v
5. 响应模型和状态码
1from fastapi import FastAPI, status2from pydantic import BaseModel34app = FastAPI()56class Item(BaseModel):7    name: str8    price: float910# 自定义状态码11@app.post("/items", status_code=status.HTTP_201_CREATED)12async def create_item(item: Item):13    return item1415# 简化写法16@app.post("/products", status_code=201)17async def create_product(product: Item):18    return product1920# 响应模型过滤21@app.post("/users", response_model=UserResponse)22async def register_user(user: UserCreate):23    # 自动过滤掉 password 等字段24    return user_data
6. 错误处理
1from fastapi import FastAPI, HTTPException, status2from pydantic import BaseModel34app = FastAPI()56fake_db = {}78@app.get("/items/{item_id}")9async def get_item(item_id: int):10    if item_id not in fake_db:11        raise HTTPException(12            status_code=status.HTTP_404_NOT_FOUND,13            detail=f"Item {item_id} not found",14            headers={"X-Error": "Not Found"}15        )16    return fake_db[item_id]1718# 自定义异常处理19from fastapi.exceptions import RequestValidationError20from fastapi.responses import JSONResponse2122@app.exception_handler(RequestValidationError)23async def validation_exception_handler(request, exc):24    return JSONResponse(25        status_code=400,26        content={"error": "验证失败", "details": exc.errors()}27    )
7. 依赖注入
1from fastapi import FastAPI, Depends, HTTPException, status2from typing import Optional34app = FastAPI()56# 简单的依赖7def common_parameters(q: Optional[str] = None, skip: int = 0, limit: int = 100):8    return {"q": q, "skip": skip, "limit": limit}910@app.get("/items")11async def read_items(commons: dict = Depends(common_parameters)):12    return commons1314# 数据库会话依赖15async def get_db():16    db = Database()17    try:18        yield db19    finally:20        db.close()2122@app.get("/users")23async def get_users(db: Database = Depends(get_db)):24    return db.query(User).all()2526# 认证依赖27async def get_current_user(token: str = Header(...)):28    user = decode_token(token)29    if not user:30        raise HTTPException(status_code=401, detail="Invalid token")31    return user3233@app.get("/me")34async def read_me(current_user: User = Depends(get_current_user)):35    return current_user
8. 中间件
1from fastapi import FastAPI, Request2from fastapi.middleware.cors import CORSMiddleware3import time45app = FastAPI()67# CORS 中间件8app.add_middleware(9    CORSMiddleware,10    allow_origins=["*"],  # 生产环境应该限制具体域名11    allow_credentials=True,12    allow_methods=["*"],13    allow_headers=["*"],14)1516# 自定义中间件17@app.middleware("http")18async def add_process_time_header(request: Request, call_next):19    start_time = time.time()20    response = await call_next(request)21    process_time = time.time() - start_time22    response.headers["X-Process-Time"] = str(process_time)23    return response
实战案例
案例 1:待办事项 API
1from fastapi import FastAPI, HTTPException, status2from pydantic import BaseModel3from typing import List, Optional4from datetime import datetime56app = FastAPI(title="Todo API")78class TodoBase(BaseModel):9    title: str10    description: Optional[str] = None11    completed: bool = False1213class TodoCreate(TodoBase):14    pass1516class TodoUpdate(BaseModel):17    title: Optional[str] = None18    description: Optional[str] = None19    completed: Optional[bool] = None2021class Todo(TodoBase):22    id: int23    created_at: datetime2425    class Config:26        from_attributes = True2728# 模拟数据库29todos_db = []30next_id = 13132@app.post("/todos", response_model=Todo, status_code=status.HTTP_201_CREATED)33async def create_todo(todo: TodoCreate):34    global next_id35    new_todo = {36        "id": next_id,37        **todo.dict(),38        "created_at": datetime.now()39    }40    todos_db.append(new_todo)41    next_id += 142    return new_todo4344@app.get("/todos", response_model=List[Todo])45async def get_todos(skip: int = 0, limit: int = 10):46    return todos_db[skip:skip+limit]4748@app.get("/todos/{todo_id}", response_model=Todo)49async def get_todo(todo_id: int):50    for todo in todos_db:51        if todo["id"] == todo_id:52            return todo53    raise HTTPException(status_code=404, detail="Todo not found")5455@app.put("/todos/{todo_id}", response_model=Todo)56async def update_todo(todo_id: int, todo_update: TodoUpdate):57    for i, todo in enumerate(todos_db):58        if todo["id"] == todo_id:59            update_data = todo_update.dict(exclude_unset=True)60            todos_db[i].update(update_data)61            return todos_db[i]62    raise HTTPException(status_code=404, detail="Todo not found")6364@app.delete("/todos/{todo_id}", status_code=status.HTTP_204_NO_CONTENT)65async def delete_todo(todo_id: int):66    for i, todo in enumerate(todos_db):67        if todo["id"] == todo_id:68            todos_db.pop(i)69            return70    raise HTTPException(status_code=404, detail="Todo not found")
案例 2:用户认证系统
1from fastapi import FastAPI, Depends, HTTPException, status2from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm3from pydantic import BaseModel, EmailStr4from datetime import datetime, timedelta5from typing import Optional6from passlib.context import CryptContext7import jwt89app = FastAPI()1011# 配置12SECRET_KEY = "your-secret-key"13ALGORITHM = "HS256"14ACCESS_TOKEN_EXPIRE_MINUTES = 301516# 密码加密17pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")18oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")1920class UserCreate(BaseModel):21    username: str22    email: EmailStr23    password: str2425class Token(BaseModel):26    access_token: str27    token_type: str2829class User(BaseModel):30    username: str31    email: EmailStr32    disabled: Optional[bool] = None3334# 模拟数据库35users_db = {}3637def verify_password(plain_password, hashed_password):38    return pwd_context.verify(plain_password, hashed_password)3940def get_password_hash(password):41    return pwd_context.hash(password)4243def create_access_token(data: dict, expires_delta: Optional[timedelta] = None):44    to_encode = data.copy()45    expire = datetime.utcnow() + (expires_delta or timedelta(minutes=15))46    to_encode.update({"exp": expire})47    return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)4849async def get_current_user(token: str = Depends(oauth2_scheme)):50    credentials_exception = HTTPException(51        status_code=status.HTTP_401_UNAUTHORIZED,52        detail="Could not validate credentials",53        headers={"WWW-Authenticate": "Bearer"},54    )55    try:56        payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])57        username: str = payload.get("sub")58        if username is None:59            raise credentials_exception60    except:61        raise credentials_exception62    user = users_db.get(username)63    if user is None:64        raise credentials_exception65    return user6667@app.post("/register", response_model=User)68async def register(user: UserCreate):69    if user.username in users_db:70        raise HTTPException(status_code=400, detail="Username already registered")7172    hashed_password = get_password_hash(user.password)73    user_data = {74        "username": user.username,75        "email": user.email,76        "hashed_password": hashed_password,77        "disabled": False78    }79    users_db[user.username] = user_data80    return {"username": user.username, "email": user.email}8182@app.post("/token", response_model=Token)83async def login(form_data: OAuth2PasswordRequestForm = Depends()):84    user = users_db.get(form_data.username)85    if not user or not verify_password(form_data.password, user["hashed_password"]):86        raise HTTPException(87            status_code=status.HTTP_401_UNAUTHORIZED,88            detail="Incorrect username or password",89            headers={"WWW-Authenticate": "Bearer"},90        )9192    access_token = create_access_token(93        data={"sub": user["username"]},94        expires_delta=timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)95    )96    return {"access_token": access_token, "token_type": "bearer"}9798@app.get("/users/me", response_model=User)99async def read_users_me(current_user: User = Depends(get_current_user)):100    return current_user
案例 3:文件上传
1from fastapi import FastAPI, File, UploadFile, HTTPException2from fastapi.responses import FileResponse3from typing import List4import shutil5from pathlib import Path67app = FastAPI()89UPLOAD_DIR = Path("uploads")10UPLOAD_DIR.mkdir(exist_ok=True)1112@app.post("/upload")13async def upload_file(file: UploadFile = File(...)):14    """上传单个文件"""15    if not file.filename:16        raise HTTPException(status_code=400, detail="No file provided")1718    file_path = UPLOAD_DIR / file.filename1920    with open(file_path, "wb") as buffer:21        shutil.copyfileobj(file.file, buffer)2223    return {"filename": file.filename, "size": file_path.stat().st_size}2425@app.post("/upload/multiple")26async def upload_multiple_files(files: List[UploadFile] = File(...)):27    """上传多个文件"""28    uploaded = []29    for file in files:30        file_path = UPLOAD_DIR / file.filename31        with open(file_path, "wb") as buffer:32            shutil.copyfileobj(file.file, buffer)33        uploaded.append({"filename": file.filename})34    return uploaded3536@app.get("/download/{filename}")37async def download_file(filename: str):38    """下载文件"""39    file_path = UPLOAD_DIR / filename40    if not file_path.exists():41        raise HTTPException(status_code=404, detail="File not found")42    return FileResponse(file_path)
异步编程
Async/Await 基础
1from fastapi import FastAPI2import asyncio3import httpx45app = FastAPI()67# 同步端点(阻塞)8@app.get("/sync")9def sync_endpoint():10    time.sleep(2)  # 阻塞 2 秒11    return {"type": "sync"}1213# 异步端点(非阻塞)14@app.get("/async")15async def async_endpoint():16    await asyncio.sleep(2)  # 非阻塞 2 秒17    return {"type": "async"}1819# 异步 HTTP 请求20@app.get("/fetch-data")21async def fetch_data():22    async with httpx.AsyncClient() as client:23        responses = await asyncio.gather(24            client.get("https://api.example.com/data1"),25            client.get("https://api.example.com/data2"),26            client.get("https://api.example.com/data3")27        )28    return [r.json() for r in responses]
后台任务
1from fastapi import FastAPI, BackgroundTasks2import time34app = FastAPI()56def send_email(email: str, message: str):7    """模拟发送邮件"""8    time.sleep(2)9    print(f"发送邮件到 {email}: {message}")1011@app.post("/send-email")12async def send_email_endpoint(13    email: str,14    background_tasks: BackgroundTasks15):16    """发送邮件(后台任务)"""17    background_tasks.add_task(send_email, email, "欢迎注册!")18    return {"message": "邮件将在后台发送"}
数据库集成
SQLAlchemy 集成
1from fastapi import FastAPI, Depends, HTTPException2from sqlalchemy import create_engine, Column, Integer, String3from sqlalchemy.ext.declarative import declarative_base4from sqlalchemy.orm import sessionmaker, Session5from pydantic import BaseModel6from typing import List, Optional78DATABASE_URL = "sqlite:///./test.db"910engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})11SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)12Base = declarative_base()1314# 数据库模型15class User(Base):16    __tablename__ = "users"1718    id = Column(Integer, primary_key=True, index=True)19    username = Column(String, unique=True, index=True)20    email = Column(String, unique=True, index=True)2122# 创建表23Base.metadata.create_all(bind=engine)2425# Pydantic 模型26class UserBase(BaseModel):27    username: str28    email: str2930class UserCreate(UserBase):31    password: str3233class UserResponse(UserBase):34    id: int3536    class Config:37        from_attributes = True3839# 依赖40def get_db():41    db = SessionLocal()42    try:43        yield db44    finally:45        db.close()4647app = FastAPI()4849@app.post("/users", response_model=UserResponse)50def create_user(user: UserCreate, db: Session = Depends(get_db)):51    db_user = User(username=user.username, email=user.email)52    db.add(db_user)53    db.commit()54    db.refresh(db_user)55    return db_user5657@app.get("/users", response_model=List[UserResponse])58def read_users(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)):59    users = db.query(User).offset(skip).limit(limit).all()60    return users
测试
使用 pytest 测试
1from fastapi.testclient import TestClient2from main import app34client = TestClient(app)56def test_read_main():7    response = client.get("/")8    assert response.status_code == 2009    assert response.json() == {"message": "Hello World"}1011def test_create_item():12    response = client.post(13        "/items",14        json={"name": "Test Item", "price": 10.0}15    )16    assert response.status_code == 20117    assert response.json()["name"] == "Test Item"1819def test_get_user_not_found():20    response = client.get("/users/999")21    assert response.status_code == 404
运行测试
1# 安装测试依赖2pip install pytest httpx34# 运行测试5pytest test_main.py -v67# 查看覆盖率8pytest --cov=main test_main.py
部署指南
使用 Docker 部署
1FROM python:3.11-slim23WORKDIR /app45# 安装依赖6COPY requirements.txt .7RUN pip install --no-cache-dir -r requirements.txt89# 复制代码10COPY . .1112# 运行应用13CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

docker-compose.yml:

1version: &#x27;3.8&#x27;23services:4  api:5    build: .6    ports:7      - "8000:8000"8    environment:9      - DATABASE_URL=postgresql://user:pass@db:5432/mydb10    depends_on:11      - db1213  db:14    image: postgres:1515    environment:16      - POSTGRES_USER=user17      - POSTGRES_PASSWORD=pass18      - POSTGRES_DB=mydb19    volumes:20      - postgres_data:/var/lib/postgresql/data2122volumes:23  postgres_data:
生产环境配置
1# config.py2from pydantic_settings import BaseSettings34class Settings(BaseSettings):5    app_name: str = "My API"6    debug: bool = False7    database_url: str8    secret_key: str910    class Config:11        env_file = ".env"1213settings = Settings()
1# main.py2from fastapi import FastAPI3from config import settings45app = FastAPI(6    title=settings.app_name,7    debug=settings.debug8)
最佳实践
1. 项目结构
1my_project/2├── app/3│   ├── __init__.py4│   ├── main.py5│   ├── config.py6│   ├── dependencies.py7│   ├── models/8│   │   ├── __init__.py9│   │   └── user.py10│   ├── schemas/11│   │   ├── __init__.py12│   │   └── user.py13│   ├── routers/14│   │   ├── __init__.py15│   │   ├── users.py16│   │   └── items.py17│   └── utils/18│       ├── __init__.py19│       └── security.py20├── tests/21│   └── test_api.py22├── requirements.txt23└── README.md
2. 使用 APIRouter 组织路由
1# app/routers/users.py2from fastapi import APIRouter34router = APIRouter(prefix="/users", tags=["users"])56@router.get("/")7async def get_users():8    return []910@router.post("/")11async def create_user():12    return {}1314# app/main.py15from fastapi import FastAPI16from app.routers import users1718app = FastAPI()19app.include_router(users.router)
3. 环境变量管理
1# .env2DATABASE_URL=postgresql://user:pass@localhost:5432/mydb3SECRET_KEY=your-secret-key4DEBUG=false
1# config.py2from pydantic_settings import BaseSettings34class Settings(BaseSettings):5    database_url: str6    secret_key: str7    debug: bool = False89    class Config:10        env_file = ".env"1112settings = Settings()
4. 日志配置
1import logging23logging.basicConfig(4    level=logging.INFO,5    format=&#x27;%(asctime)s - %(name)s - %(levelname)s - %(message)s&#x27;6)78logger = logging.getLogger(__name__)910@app.get("/items")11async def get_items():12    logger.info("获取物品列表")13    return []
常见问题
Q1: FastAPI 和 Flask 选哪个?

FastAPI 适合:

  • 构建 API 服务
  • 需要高性能
  • 需要自动文档
  • 需要类型安全

Flask 适合:

  • 简单 Web 应用
  • 需要完整模板引擎
  • 项目已有 Flask 生态
Q2: 如何处理 CORS 错误?
1from fastapi.middleware.cors import CORSMiddleware23app.add_middleware(4    CORSMiddleware,5    allow_origins=["http://localhost:3000"],6    allow_credentials=True,7    allow_methods=["*"],8    allow_headers=["*"],9)
Q3: 如何实现分页?
1@app.get("/items")2async def get_items(page: int = 1, page_size: int = 10):3    skip = (page - 1) * page_size4    items = db.query(Item).offset(skip).limit(page_size).all()5    return {"items": items, "total": total_count}
学习资源
  • 📚 FastAPI 官方文档
  • 🎓 FastAPI 中文教程
  • 💻 FastAPI GitHub
  • 🎥 FastAPI 视频教程
  • 💬 FastAPI Discord
总结

通过本文的学习,你应该掌握了:✅ FastAPI 的核心特性和优势  ✅ 路径参数、查询参数和请求体  ✅ Pydantic 数据验证  ✅ 依赖注入系统  ✅ 异步编程和后台任务  ✅ 数据库集成  ✅ 测试和部署  ✅ 最佳实践  FastAPI 是一个强大且易用的现代 Web 框架。现在就开始构建你的第一个 FastAPI 应用吧!🚀

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 09:53:25 HTTP/2.0 GET : https://f.mffb.com.cn/a/483157.html
  2. 运行时间 : 0.185916s [ 吞吐率:5.38req/s ] 内存消耗:4,953.27kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=57b5ba08ea137031ada37a3c9f74b797
  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.000572s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000909s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001207s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.004603s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000575s ]
  6. SELECT * FROM `set` [ RunTime:0.002864s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000640s ]
  8. SELECT * FROM `article` WHERE `id` = 483157 LIMIT 1 [ RunTime:0.000700s ]
  9. UPDATE `article` SET `lasttime` = 1774576405 WHERE `id` = 483157 [ RunTime:0.004785s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.001373s ]
  11. SELECT * FROM `article` WHERE `id` < 483157 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000722s ]
  12. SELECT * FROM `article` WHERE `id` > 483157 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.003962s ]
  13. SELECT * FROM `article` WHERE `id` < 483157 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.024762s ]
  14. SELECT * FROM `article` WHERE `id` < 483157 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.020172s ]
  15. SELECT * FROM `article` WHERE `id` < 483157 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.009952s ]
0.188233s