|
@@ -1,8 +1,39 @@
|
|
|
-# main.py
|
|
|
+# from fastapi import FastAPI
|
|
|
+
|
|
|
+# app = FastAPI()
|
|
|
+
|
|
|
+# # 书籍列表
|
|
|
+# books = [
|
|
|
+# {"id": 1, "title": "Book 1", "author": "Author 1"},
|
|
|
+# {"id": 2, "title": "Book 2", "author": "Author 2"},
|
|
|
+# {"id": 3, "title": "Book 3", "author": "Author 3"}
|
|
|
+# ]
|
|
|
+
|
|
|
+
|
|
|
+# @app.get("/books/{book_id}")
|
|
|
+# async def get_book(book_id: int):
|
|
|
+# for book in books:
|
|
|
+# if book["id"] == book_id:
|
|
|
+# return book
|
|
|
+# return {"message": "Book not found"}
|
|
|
+
|
|
|
+
|
|
|
+# @app.get("/books")
|
|
|
+# async def get_books():
|
|
|
+# return books
|
|
|
+
|
|
|
from fastapi import FastAPI
|
|
|
-from api-demo.v1. import login
|
|
|
+from api_demo.v1.impl.BookImpl import book_router
|
|
|
+from api_demo.v1.impl.MusicImpl import music_router
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
-# 注册路由
|
|
|
-app.include_router(login.router)
|
|
|
+# 注册书籍相关的路由
|
|
|
+app.include_router(book_router, prefix="/books", tags=["books"])
|
|
|
+
|
|
|
+# 注册音乐搜索相关的路由
|
|
|
+app.include_router(music_router, prefix="/music", tags=["music"])
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ import uvicorn
|
|
|
+ uvicorn.run(app, host="127.0.0.1", port=8000)
|