Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)48k · #4599

fastapi-router-py

Skill này làm gì

Đoạn mã này giúp tạo các phần của trang web hoặc ứng dụng web để xử lý thông tin, đảm bảo thông tin được tổ chức và an toàn. Nó định nghĩa cách dữ liệu được nhận và gửi, và ai có quyền truy cập.

Khi nào nên dùng

  • ✓Khi xây dựng các phần mới cho một trang web.
  • ✓Khi thêm tính năng đăng nhập hoặc phân quyền.
  • ✓Khi tổ chức cách dữ liệu được hiển thị cho người dùng.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fastapi-router-py/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fastapi-router-py/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một phần mới để quản lý người dùng trong ứng dụng của tôi, với đăng nhập an toàn và danh sách người dùng.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Nó dùng một mẫu để định nghĩa cấu trúc dữ liệu và các quy tắc đảm bảo chỉ người dùng được ủy quyền mới truy cập được một số thông tin nhất định. Nó cũng đặt mã trạng thái để báo cho biết thao tác có thành công hay không.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Bundled upstream support

Supporting files are included at skill-relative paths. See UPSTREAM-NOTICE.md for their pinned sources, licenses, hashes, and import changes.

FastAPI Router

Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.

Quick Start

Copy the template from assets/template.py and replace placeholders:

  • {{ResourceName}} → PascalCase name (e.g., Project)
  • {{resource_name}} → snake_case name (e.g., project)
  • {{resource_plural}} → plural form (e.g., projects)

Authentication Patterns

# Optional auth - returns None if not authenticated
current_user: Optional[User] = Depends(get_current_user)

# Required auth - raises 401 if not authenticated
current_user: User = Depends(get_current_user_required)

Response Models

@router.get("/items/{item_id}", response_model=Item)
async def get_item(item_id: str) -> Item:
    ...

@router.get("/items", response_model=list[Item])
async def list_items() -> list[Item]:
    ...

HTTP Status Codes

@router.post("/items", status_code=status.HTTP_201_CREATED)
@router.delete("/items/{id}", status_code=status.HTTP_204_NO_CONTENT)

Integration Steps

  1. Create router in src/backend/app/routers/
  2. Mount in src/backend/app/main.py
  3. Create corresponding Pydantic models
  4. Create service layer if needed
  5. Add frontend API functions

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Câu hỏi thường gặp

'Routers' là gì?

Chúng giống như các khu trong một tòa nhà, mỗi tầng hoặc phòng có chức năng riêng. Trong mã, chúng tổ chức các phần khác nhau của một ứng dụng web.

'Xác thực' là gì?

Đó là quá trình kiểm tra xem người dùng có đúng là người họ tự nhận hay không, giống như đăng nhập bằng tên người dùng và mật khẩu.

'Response models' là gì?

Chúng giống như các biểu mẫu xác định giao diện và dữ liệu sẽ được gửi lại cho người dùng, đảm bảo tính nhất quán.

Chi tiết

Mô tả gốc của tác giả

Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4599
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự