22 lines
997 B
Python
22 lines
997 B
Python
Here's the `__init__.py` file for the `app/api/v1/routes/` directory, which aggregates the routers for posts, comments, tags, and user:
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from .posts import router as posts_router
|
|
from .comments import router as comments_router
|
|
from .tags import router as tags_router
|
|
from .user import router as user_router
|
|
|
|
router = APIRouter()
|
|
|
|
router.include_router(posts_router, prefix="/posts", tags=["posts"])
|
|
router.include_router(comments_router, prefix="/comments", tags=["comments"])
|
|
router.include_router(tags_router, prefix="/tags", tags=["tags"])
|
|
router.include_router(user_router, prefix="/user", tags=["user"])
|
|
|
|
Explanation:
|
|
|
|
- `prefix` is used to define the base URL path for each router.
|
|
- `tags` is used to group related routes in the automatically generated API documentation.
|
|
|
|
Note: Make sure that the `posts.py`, `comments.py`, `tags.py`, and `user.py` files exist in the same directory (`app/api/v1/routes/`) and contain the respective router definitions. |