1fastapi.py 755 B

1234567891011121314151617181920212223242526272829303132333435
  1. from fastapi import FastAPI
  2. # web服务器
  3. import uvicorn
  4. from api.book import api_book
  5. from api.cbs import api_cbs
  6. from api.zz import api_zz
  7. app = FastAPI()
  8. app.include_router(api_book, prefix="/book", tags=["book interface"])
  9. app.include_router(api_cbs, prefix="/cbs", tags=["cbs interface"])
  10. app.include_router(api_zz, prefix="/zz", tags=["zz interface"])
  11. @app.get("/")
  12. async def root():
  13. return {"message": "Hello World"}
  14. @app.get("/get")
  15. async def get_test():
  16. return {"method": "get method"}
  17. @app.post("/post")
  18. async def post_test():
  19. return {"method": "post method"}
  20. @app.put("/put")
  21. async def put_test():
  22. return {"method": "put method"}
  23. @app.delete("/delete")
  24. async def delete_test():
  25. return {"method": "delete method"}