main.py 663 B

12345678910111213141516171819202122232425262728293031323334
  1. from fastapi import FastAPI
  2. import sys
  3. import os
  4. sys.path.insert(0,'.')
  5. import bhouse_lib
  6. app = FastAPI()
  7. @app.get("/items/{item_id}")
  8. async def read_item(item_id):
  9. return {"item_id": item_id}
  10. @app.get("/bhouse/{month_num}")
  11. async def montyly_rep(month_num):
  12. rep=bhouse_lib.get_monthly_report(int(month_num))
  13. return {"results": rep}
  14. @app.get("/bhouse/kw/{month_num}")
  15. async def montyly_kw(month_num):
  16. rep=bhouse_lib.get_monthly_report(int(month_num))
  17. results=[]
  18. for r in rep:
  19. if r[4] <=4:
  20. results.append(r)
  21. return {"results": results}
  22. @app.get("/")
  23. async def root():
  24. return {"message": "Hello World"}